-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHomePage.java
186 lines (145 loc) · 5.68 KB
/
HomePage.java
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
class HomePage extends JFrame{
private AddContactForm addContactForm;
private UpdateContactForm updateContactForm;
private SearchContactForm searchContactForm;
private DeleteContactForm deleteContactForm;
private SortContactForm sortContactForm;
private JButton btnAddContact;
private JButton btnUpdateContact;
private JButton btnSearchContact;
private JButton btnDeleteContact;
private JButton btnViewContact;
private JButton btnExit;
private JLabel iFriendLabel;
private JLabel contactLabel;
private JLabel homeLabel;
private JLabel mainImageLabel;
public HomePage(){
setSize(900,600);
//setTitle("iFriend Contact Organizer");
setDefaultCloseOperation(EXIT_ON_CLOSE);
setResizable(false);
setLocationRelativeTo(null);
setLayout(new BorderLayout());
// ImageIcon main_img = new ImageIcon("i.jpg");
// Image scaledImage = main_img.getImage().getScaledInstance(400, 300, Image.SCALE_SMOOTH);
// ImageIcon resizedImageIcon = new ImageIcon(scaledImage);
JPanel westPanel=new JPanel(null);
westPanel.setPreferredSize(new Dimension(400, 600));
iFriendLabel=new JLabel("iFRIEND");
iFriendLabel.setFont(new Font("",1,40));
iFriendLabel.setBounds(50,0,300,100);
iFriendLabel.setHorizontalAlignment(SwingConstants.CENTER);
westPanel.add("Center",iFriendLabel);
contactLabel =new JLabel("Contact Manager");
contactLabel.setFont(new Font("",1,40));
contactLabel.setBounds(10,50,380,130);
contactLabel.setHorizontalAlignment(SwingConstants.CENTER);
westPanel.add("Center",contactLabel);
JSeparator separator = new JSeparator(SwingConstants.HORIZONTAL);
separator.setBounds(10, 150, 400, 5);
westPanel.add(separator);
// ImageIcon mainImage = new image("HomeImage.jpg");
// ImageIcon scaledImage = mainImage.getImage().getScaledInstance(400, 400, Image.SCALE_SMOOTH);
// ImageIcon resizedImageIcon = new ImageIcon(scaledImage);
// mainImage.setBounds(10,50,400,400);
// mainImage.setHorizontalAlignment(SwingConstants.CENTER);
// westPanel.add("Center",mainImage);
ImageIcon mainImageIcon = new ImageIcon("HomeImage.jpg");
Image scaledImage = mainImageIcon.getImage().getScaledInstance(350, 350, Image.SCALE_SMOOTH);
mainImageIcon = new ImageIcon(scaledImage);
mainImageLabel = new JLabel(mainImageIcon);
mainImageLabel.setBounds(5,180,400,320);
mainImageLabel.setHorizontalAlignment(SwingConstants.CENTER);
westPanel.add(mainImageLabel);
add(westPanel, BorderLayout.WEST);
JPanel eastPanel=new JPanel(null);
eastPanel.setPreferredSize(new Dimension(550, 600));
eastPanel.setBackground(new Color(95, 119, 222));
eastPanel.setLayout(null);
homeLabel=new JLabel("Home Page");
homeLabel.setFont(new Font("",1,40));
homeLabel.setBounds(120,25,380,70);
homeLabel.setHorizontalAlignment(SwingConstants.CENTER);
eastPanel.add(homeLabel);
separator = new JSeparator(SwingConstants.HORIZONTAL);
separator.setBounds(50, 105, 500, 5);
eastPanel.add(separator);
btnAddContact=new JButton("Add Contacts");
btnAddContact.setFont(new Font("",1,21));
btnAddContact.setBounds(160,140,300,32);
btnAddContact.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
if(addContactForm==null){
addContactForm=new AddContactForm();
}
addContactForm.setVisible(true);
}
});
eastPanel.add(btnAddContact);
btnUpdateContact=new JButton("Update Contacts");
btnUpdateContact.setFont(new Font("",1,21));
btnUpdateContact.setBounds(160,200,300,32);
btnUpdateContact.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
if(updateContactForm==null){
updateContactForm=new UpdateContactForm();
}
updateContactForm.setVisible(true);
}
});
eastPanel.add(btnUpdateContact);
btnDeleteContact=new JButton("Delete Contacts");
btnDeleteContact.setFont(new Font("",1,21));
btnDeleteContact.setBounds(160,260,300,32);
btnDeleteContact.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
if(deleteContactForm==null){
deleteContactForm=new DeleteContactForm();
}
deleteContactForm.setVisible(true);
}
});
eastPanel.add(btnDeleteContact);
btnSearchContact=new JButton("Search Contacts");
btnSearchContact.setFont(new Font("",1,21));
btnSearchContact.setBounds(160,320,300,32);
btnSearchContact.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
if(searchContactForm==null){
searchContactForm=new SearchContactForm();
}
searchContactForm.setVisible(true);
}
});
eastPanel.add(btnSearchContact);
btnViewContact=new JButton("View Contacts");
btnViewContact.setFont(new Font("",1,21));
btnViewContact.setBounds(160,380,300,32);
btnViewContact.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
if(sortContactForm==null){
sortContactForm=new SortContactForm();
}
sortContactForm.setVisible(true);
}
});
eastPanel.add(btnViewContact);
btnExit=new JButton("Exit");
btnExit.setFont(new Font("",1,21));
btnExit.setBounds(400,480,100,32);
btnExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent evt){
System.exit(0);
}
});
eastPanel.add(btnExit);
add(eastPanel, BorderLayout.EAST);
}
public static void main(String args[]){
new HomePage().setVisible(true);
}
}