
コンテナ
1 package com.tkadvance;
2
3 import java.awt.BorderLayout;
4 import javax.swing.JButton;
5 import javax.swing.JFrame;
6 import javax.swing.JLabel;
7 import javax.swing.JPanel;
8
9 public class SampleContainer extends JFrame{
10
11 private static final long serialVersionUID = 1L;
12
13 public SampleContainer() {
14 this.setTitle("サンプルコンテナ");
15 this.setDefaultCloseOperation(EXIT_ON_CLOSE);
16
17 JPanel panel1 = new JPanel();
18 JLabel label1 = new JLabel("1.");
19 panel1.add(label1);
20 JButton button1 = new JButton("ok");
21 panel1.add(button1);
22 getContentPane().add(panel1, BorderLayout.NORTH);
23
24 JPanel panel2 = new JPanel();
25 JLabel label2 = new JLabel("2.");
26 panel2.add(label2);
27 JButton button2 = new JButton("ok");
28 panel2.add(button2);
29 getContentPane().add(panel2, BorderLayout.CENTER);
30 this.pack();
31 this.setVisible(true);
32 }
33
34 public static void main(String[] args) {
35 new SampleContainer();
36 }
37
38 }
|