-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHomeFrame.java
More file actions
76 lines (59 loc) · 2.08 KB
/
HomeFrame.java
File metadata and controls
76 lines (59 loc) · 2.08 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
package app;
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
import app.*;
public class HomeFrame extends JFrame{
public JButton add,view,delete,modify;
JPanel jp;
public HomeFrame()
{
setVisible(true); //JFrame properties starts
setLocationRelativeTo(null);
setSize(500,150);
setTitle("Employee Records Management");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); //JFrame properties ends
createAndAddButtons();
//Creates buttons and add to JPanel
add(jp); //Adds the JPanel to JFrame
}
public void createAndAddButtons()
{
add = new JButton("Add");
view = new JButton("View");
delete = new JButton("Delete");
modify = new JButton("Modify");
jp = new JPanel();
jp.setLayout(new FlowLayout(FlowLayout.CENTER,10,25));
//Add all buttons to JPanel
jp.add(add);
jp.add(view);
jp.add(delete);
jp.add(modify);
//Adds Action Listeners
add.addActionListener(new ListenIt());
view.addActionListener(new ListenIt());
delete.addActionListener(new ListenIt());
modify.addActionListener(new ListenIt());
}
class ListenIt implements ActionListener
{
public void actionPerformed(ActionEvent a)
{
if(a.getSource() == add)
new AddFrame(); //Open window of Add Frame
else if(a.getSource() == view)
new ViewFrame(); //Open window of View Frame
else if(a.getSource() == delete)
new DeleteFrame(); //Open window of Delete Frame
else if(a.getSource() == modify)
new ModifyFrame(); //Open window of Modify Frame
dispose(); //Close Current Home Frame Window
}
}
public static void main(String a[])
{
HomeFrame h = new HomeFrame();
}
}