-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMainFrame.java
More file actions
134 lines (113 loc) · 4.61 KB
/
MainFrame.java
File metadata and controls
134 lines (113 loc) · 4.61 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
import java.awt.*;
import javax.swing.*;
class MainFrame {
public static void main(String args[]) {
Font subLabel = new Font("Arial", Font.BOLD, 16);
JFrame frame = new JFrame("Expense Tracker");
frame.setSize(600, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(null); // Absolute positioning
frame.setLocationRelativeTo(null);
// Title Label
JLabel titleLabel = new JLabel("Expense Tracker");
titleLabel.setFont(new Font("Arial", Font.BOLD, 24));
titleLabel.setBounds(200, 20, 250, 30);
frame.add(titleLabel);
// Income Label
JLabel incomeLabel = new JLabel("Total Income:");
incomeLabel.setFont(subLabel);
incomeLabel.setBounds(50, 80, 150, 25);
frame.add(incomeLabel);
// Income Text Field
JTextField inTextField = new JTextField();
inTextField.setBounds(200, 80, 150, 25);
frame.add(inTextField);
// Expense Label
JLabel expenseLabel = new JLabel("Total Expenses:");
expenseLabel.setFont(subLabel);
expenseLabel.setBounds(50, 120, 150, 25);
frame.add(expenseLabel);
// Expense Text Field
JTextField exTextField = new JTextField();
exTextField.setBounds(200, 120, 150, 25);
frame.add(exTextField);
// Balance Label
JLabel balanceLabel = new JLabel("Remaining Balance:");
balanceLabel.setFont(subLabel);
balanceLabel.setBounds(50, 160, 180, 25);
frame.add(balanceLabel);
// Balance Text Field
JTextField balTextField = new JTextField();
balTextField.setBounds(230, 160, 150, 25);
frame.add(balTextField);
// Category Label
JLabel categoryLabel = new JLabel("Expense Category:");
categoryLabel.setFont(subLabel);
categoryLabel.setBounds(50, 200, 180, 25);
frame.add(categoryLabel);
// Category Combo Box
String[] category = {
"", "Household & Living", "Food", "Transportation", "Health", "Shopping/Personal",
"Travel", "Education", "Work", "Financial", "Miscellaneous"
};
JComboBox<String> catComboBox = new JComboBox<>(category);
catComboBox.setBounds(230, 200, 180, 25);
frame.add(catComboBox);
// Date Label
JLabel dateLabel = new JLabel("Date:");
dateLabel.setFont(subLabel);
dateLabel.setBounds(50, 240, 150, 25);
frame.add(dateLabel);
// Day Combo Box
Integer[] day = new Integer[31];
for (int i = 0; i < 31; i++) {
day[i] = i + 1;
}
JComboBox<Integer> dayComboBox = new JComboBox<>(day);
dayComboBox.setBounds(200, 240, 50, 25);
frame.add(dayComboBox);
// Month Combo Box
String[] month = {
"January", "February", "March", "April", "May", "June",
"July", "August", "September", "October", "November", "December"
};
JComboBox<String> monthComboBox = new JComboBox<>(month);
monthComboBox.setBounds(250, 240, 100, 25);
frame.add(monthComboBox);
// Year Combo Box
Integer[] year = new Integer[16];
for (int i = 0; i < 16; i++) {
year[i] = 2020 + i;
}
JComboBox<Integer> yearComboBox = new JComboBox<>(year);
yearComboBox.setBounds(350, 240, 70, 25);
frame.add(yearComboBox);
// Description Label
JLabel descriptionLabel = new JLabel("Description:");
descriptionLabel.setFont(subLabel);
descriptionLabel.setBounds(50, 290, 150, 25);
frame.add(descriptionLabel);
// Description Text Area
JTextArea desTextArea = new JTextArea();
desTextArea.setLineWrap(true);
desTextArea.setWrapStyleWord(true);
JScrollPane scrollPane = new JScrollPane(desTextArea);
scrollPane.setBounds(200, 280, 250, 60); // Adjusted size
frame.add(scrollPane);
// Amount Label
JLabel amountLabel = new JLabel("Amount:");
amountLabel.setFont(subLabel);
amountLabel.setBounds(50, 360, 150, 25);
frame.add(amountLabel);
// Amount Text Field
JTextField amountTextField = new JTextField();
amountTextField.setBounds(200, 360, 150, 25);
frame.add(amountTextField);
// Submit Button
JButton submitButton = new JButton("Submit");
submitButton.setFont(new Font("Arial", Font.BOLD, 16));
submitButton.setBounds(230, 410, 100, 30); // Positioned below Amount field
frame.add(submitButton);
frame.setVisible(true);
}
}