-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddApplication.java
More file actions
149 lines (124 loc) · 5.26 KB
/
AddApplication.java
File metadata and controls
149 lines (124 loc) · 5.26 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
package com.mycompany.addApplications;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableModel;
/**
*
* @author gameo
*/
public class AddApplicationFrame extends JFrame {
private JTable table;
private DefaultTableModel tableModel;
private JTextField companyNameField;
private JTextField positionField;
private JTextField statusField;
private JTextField dateField;
public AddApplicationFrame() {
setTitle("Job Application Tracker");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setSize(800, 600);
setLayout(new BorderLayout());
// Header Panel
JPanel headerPanel = new JPanel();
headerPanel.setBackground(new Color(70, 130, 180)); // Steel Blue
JLabel headerLabel = new JLabel("Add Applications");
headerLabel.setFont(new Font("Serif", Font.BOLD, 36));
headerLabel.setForeground(Color.WHITE);
headerPanel.add(headerLabel);
add(headerPanel, BorderLayout.NORTH);
// Table Setup
String[] columnNames = {"Company Name", "Position", "Status", "Due-Date"};
tableModel = new DefaultTableModel(columnNames, 0);
table = new JTable(tableModel);
JScrollPane scrollPane = new JScrollPane(table);
// Input Panel Setup
JPanel inputPanel = new JPanel(new GridLayout(2, 5, 10, 10));
JLabel companyNameLabel = new JLabel("Company Name:");
companyNameField = new JTextField();
JLabel positionLabel = new JLabel("Position:");
positionField = new JTextField();
JLabel statusLabel = new JLabel("Status:");
statusField = new JTextField();
JLabel dateLabel = new JLabel("Due-Date:");
dateField = new JTextField();
JButton addButton = new JButton("Add");
addButton.addActionListener(new AddButtonListener());
JButton deleteButton = new JButton("Delete Selected");
deleteButton.addActionListener(new DeleteButtonListener());
inputPanel.add(companyNameLabel);
inputPanel.add(companyNameField);
inputPanel.add(positionLabel);
inputPanel.add(positionField);
inputPanel.add(statusLabel);
inputPanel.add(statusField);
inputPanel.add(dateLabel);
inputPanel.add(dateField);
inputPanel.add(addButton);
inputPanel.add(deleteButton);
// Adding Components
JPanel southPanel = new JPanel();
southPanel.setLayout(new BorderLayout());
JPanel statusBar = new JPanel(new FlowLayout(FlowLayout.LEFT));
statusBar.add(inputPanel);
add(scrollPane, BorderLayout.CENTER);
// add(inputPanel, BorderLayout.SOUTH);
// Footer Panel
JPanel footerPanel = new JPanel();
footerPanel.setBackground(new Color(70, 130, 180)); // Steel Blue
JLabel footerLabel = new JLabel("© 2025 Job Application Tracker. All Rights Reserved.", JLabel.CENTER);
footerLabel.setForeground(Color.WHITE);
footerPanel.add(footerLabel);
southPanel.add(statusBar, BorderLayout.NORTH);
southPanel.add(footerPanel, BorderLayout.SOUTH);
add(southPanel, BorderLayout.SOUTH);
setVisible(true);
}
private class AddButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
String companyName = companyNameField.getText().trim();
String position = positionField.getText().trim();
String status = statusField.getText().trim();
String date = dateField.getText().trim();
if (companyName.isEmpty() || position.isEmpty() || status.isEmpty() || date.isEmpty()) {
JOptionPane.showMessageDialog(AddApplicationFrame.this,
"All fields must be filled out.", "Input Error", JOptionPane.ERROR_MESSAGE);
return;
}
tableModel.addRow(new Object[]{companyName, position, status, date});
companyNameField.setText("");
positionField.setText("");
statusField.setText("");
dateField.setText("");
}
}
private class DeleteButtonListener implements ActionListener {
@Override
public void actionPerformed(ActionEvent e) {
int selectedRow = table.getSelectedRow();
if (selectedRow == -1) {
JOptionPane.showMessageDialog(AddApplicationFrame.this,
"Please select a row to delete.", "No Selection", JOptionPane.WARNING_MESSAGE);
} else {
tableModel.removeRow(selectedRow);
}
}
}
public static void main(String[] args) {
new AddApplicationFrame();
}
}