-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPhoneBook.java
More file actions
53 lines (42 loc) · 1.32 KB
/
Copy pathPhoneBook.java
File metadata and controls
53 lines (42 loc) · 1.32 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
// Programmer: Edgar Colin
// Student ID: EDG2140344
// Class: CIS263AA JAVA II Class # 12303
// Instructor: Michael Parmeley
// Chapter: 14
// Problem: 2
// Part:
// Filename: PhoneBook.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class PhoneBook extends JFrame
implements ActionListener
{
String[] list = {"Select Name","Carol", "Edgar", "John", "Susan" , "Erik"};
JLabel description = new JLabel("Phone Directory");
JComboBox pNumberBox = new JComboBox(list);
JLabel dispName = new JLabel("Select a name from the drop down list");
public PhoneBook()
{
super("Phone List");
setSize(300, 100);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(new FlowLayout());
add(description);
add(pNumberBox);
add(dispName);
pNumberBox.addActionListener(this);
setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
String[] Phone = {""," : 313-567-2321"," : 313-432-2353"," : 313-896-7483",
" : 313-593-7562", " : 708-484-4342"};
int index = pNumberBox.getSelectedIndex();
dispName.setText( list[index] + Phone[index]);
}
public static void main(String[] args)
{
PhoneBook demo = new PhoneBook();
}
}