-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainForm.java
More file actions
120 lines (104 loc) · 3.03 KB
/
MainForm.java
File metadata and controls
120 lines (104 loc) · 3.03 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
import java.io.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.applet.*;
@SuppressWarnings("all")
public class MainForm extends JFrame implements ActionListener
{
private JButton cmd_Add,cmd_Birthday,cmd_Anniversary,cmd_Address,cmd_UpdateDelete,cmd_Search,cmd_exit;
private JLabel mainLabel;
public MainForm(String fname)
{
super(fname);
getContentPane().setLayout(new BorderLayout());
JPanel panel1=new JPanel();
panel1.setLayout(new GridLayout(4,1,10,5));
JPanel panel=new JPanel();
panel.setLayout(new FlowLayout());
mainLabel=new JLabel("B. R. Enterprises");
panel.add(mainLabel);
cmd_Add=new JButton("Add Contact");
cmd_UpdateDelete=new JButton("Update/Delete Contact");
cmd_Search=new JButton("Search Contact");
cmd_exit=new JButton("Exit");
panel1.add(cmd_Add);
panel1.add(cmd_UpdateDelete);
panel1.add(cmd_Search);
panel1.add(cmd_exit);
getContentPane().add(panel,BorderLayout.NORTH);
getContentPane().add(panel1,BorderLayout.CENTER);
cmd_Add.addActionListener(this);
cmd_UpdateDelete.addActionListener(this);
cmd_Search.addActionListener(this);
cmd_exit.addActionListener(this);
addWindowListener(new MyWindowAdapter());
}
class MyWindowAdapter extends WindowAdapter
{
public void windowClosing(WindowEvent we)
{
//setVisible(false);
//LoginForm loginform=new LoginForm("Login Form");
//loginform.setLocation(200,150);
//loginform.setSize(300,150);
//loginform.setResizable(false);
//loginform.setVisible(true);
//dispose();
System.exit(0);
}
}
/*public void run()
{
try
{
Thread.sleep(1000);
} catch(InterruptedException ie) {}
repaint();
}
public void update(Graphics g)
{
mainLabel.setVisible(!(mainLabel.isVisible()));
}
*/
public void actionPerformed(ActionEvent ae)
{
if(ae.getSource()==cmd_Add)
{
AddForm addform=new AddForm("Add Contact Form");
addform.setLocation(this.getX(),this.getY());
addform.setSize(300,250);
addform.setResizable(false);
addform.setVisible(true);
setVisible(false);
}
else if(ae.getSource()==cmd_UpdateDelete)
{
UpdateDeleteForm udform=new UpdateDeleteForm("Update Delete Form");
udform.setLocation(this.getX(),this.getY());
udform.setSize(300,300);
udform.setResizable(false);
udform.setVisible(true);
setVisible(false);
}
else if(ae.getSource()==cmd_Search)
{
SearchForm sform=new SearchForm("Search Contact Form");
sform.setLocation(this.getX(),this.getY());
sform.setSize(300,300);
sform.setResizable(false);
sform.setVisible(true);
setVisible(false);
}
else if(ae.getSource()==cmd_exit)
{
/*setVisible(false);
LoginForm loginform=new LoginForm("Login Form");
loginform.setLocation(250,150);
loginform.setSize(300,150);
loginform.setResizable(false);
loginform.setVisible(true);*/
dispose();
}
}
}