-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathBorderLocation.java
More file actions
93 lines (87 loc) · 2.18 KB
/
Copy pathBorderLocation.java
File metadata and controls
93 lines (87 loc) · 2.18 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
// Programmer: Edgar Colin
// Student ID: EDG2140344
// Class: CIS263AA JAVA II Class # 12303
// Instructor: Michael Parmeley
// Chapter: 15
// Problem: 1
// Part:
// Filename: BorderLocation.java
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class BorderLocation extends
JFrame implements ActionListener
{
private JButton nb = new JButton("");
private JButton sb = new JButton("");
private JButton eb = new JButton("");
private JButton wb = new JButton("");
private JButton cb = new JButton("");
public Container con = getContentPane();
public BorderLocation()
{
con.setLayout(new BorderLayout());
con.add(nb, BorderLayout.NORTH);
con.add(sb, BorderLayout.SOUTH);
con.add(eb, BorderLayout.EAST);
con.add(wb, BorderLayout.WEST);
con.add(cb, BorderLayout.CENTER);
nb.addActionListener(this);
sb.addActionListener(this);
eb.addActionListener(this);
wb.addActionListener(this);
cb.addActionListener(this);
setSize(400, 150);
}
public void actionPerformed(ActionEvent event)
{
Object source = event.getSource();
if(source == nb)
{
nb.setText("North");
sb.setText("");
eb.setText("");
wb.setText("");
cb.setText("");
}
else if (source == sb)
{
nb.setText("");
sb.setText("South");
eb.setText("");
wb.setText("");
cb.setText("");
}
else if (source == eb)
{
nb.setText("");
sb.setText("");
eb.setText("East");
wb.setText("");
cb.setText("");
}
else if (source == wb)
{
nb.setText("");
sb.setText("");
eb.setText("");
wb.setText("West");
cb.setText("");
}
else
{
nb.setText("");
sb.setText("");
eb.setText("");
wb.setText("");
cb.setText("Center");
}
con.invalidate();
con.validate();
}
public static void main(String[] args)
{
BorderLocation frame = new BorderLocation();
frame.setVisible(true);
}
}