import javax.swing.*;
import java.awt.*;
public class Chapter9 extends JFrame {
public Chapter9() {
setTitle("openChallenge 9");
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Container c = getContentPane();
c.add(new NorthPanel(), BorderLayout.NORTH);
c.add(new CenterPanel(), BorderLayout.CENTER);
setSize(400, 500);
setVisible(true);
}
static public void main(String [] args) {
new Chapter9();
}
}
class NorthPanel extends JPanel {
NorthPanel() {
setBackground(Color.LIGHT_GRAY);
setLayout(new FlowLayout(FlowLayout.CENTER, 5 ,5));
add(new JButton("open"));
add(new JButton("Read"));
add(new JButton("Close"));
}
}
class CenterPanel extends JPanel {
CenterPanel() {
JLabel lb;
setLayout(null);
lb = new JLabel("Hello");
lb.setLocation(100, 50);
lb.setSize(200,20);
add(lb);
lb = new JLabel("Love");
lb.setLocation(10, 200);
lb.setSize(200,20);
add(lb);
lb = new JLabel("Java");
lb.setLocation(239, 400);
lb.setSize(200,20);
add(lb);
}
}