This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAddressBook.java
64 lines (56 loc) · 1.86 KB
/
AddressBook.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class AddressBook {
// Components
private JFrame f;
private JPanel p = new JPanel();
private JButton view;
private JButton create;
//. Components
public AddressBook(){
// Frame Functionalities
f = new JFrame("Address Book"); // Frame create & Name
f.setLayout(new FlowLayout()); // Frame Layout
f.setSize(300,100); // Frame Size
f.setLocationRelativeTo(null); // Frame Location ==> set to middle of the screen
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Frame close operation
//. Frame functionalities
// panels
//p = new JPanel();
// Buttons
create = new JButton("Add New");
view = new JButton("View Contacts");
//. Buttons
// Create Button Actions
create.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new AddNew();
f.setVisible(false);
}
});
//. Create Button Actions
// View Button Actions
view.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
new ViewContacts();
f.setVisible(false);
}
});
//. View Button Actions
// Adding Buttons to panel
p.add(create);
p.add(view);
//. Adding Buttons to panel
// Adding panel to frame & Frame visibility
f.add(p);
f.setVisible(true);
//. Adding panel to frame & Frame visibility
}
public static void main(String[] args) {
new AddressBook();
}
}