-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgui.java
More file actions
56 lines (43 loc) · 1.45 KB
/
gui.java
File metadata and controls
56 lines (43 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class gui implements ActionListener {
JTextField amtField = new JTextField(10);
JTextField descField = new JTextField(50);
JButton addBtn = new JButton("Add");
public gui(){
JFrame frame = new JFrame("Expense Manager");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JMenuBar menubar = new JMenuBar();
JMenu createMenu = new JMenu("Add Expense");
JMenu listMenu = new JMenu("List Expenses");
menubar.add(createMenu);
menubar.add(listMenu);
JLabel amtLabel = new JLabel("Enter Amount");
JLabel descLabel = new JLabel("Enter Description");
JPanel panel = new JPanel();
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
panel.add(amtLabel);
panel.add(amtField);
panel.add(Box.createVerticalGlue());
panel.add(descLabel);
panel.add(descField);
panel.add(Box.createVerticalGlue());
panel.add(addBtn);
frame.add(panel);
frame.pack();
frame.setVisible(true);
addBtn.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() == addBtn) {
String amtIn = amtField.getText();
Float amt = Float.parseFloat(amtIn);
String desc = descField.getText();
}
}
public static void main(String args[]){
gui g = new gui();
}
}