
コンテナ2
1 package com.tkadvance;
2
3 import javax.swing.Box;
4 import javax.swing.JButton;
5 import javax.swing.JFrame;
6
7 public class SampleBox extends JFrame{
8
9 private static final long serialVersionUID = 1L;
10
11 public SampleBox() {
12 this.setTitle("サンプルコンテナ 2-Box");
13 this.setDefaultCloseOperation(EXIT_ON_CLOSE);
14
15 Box box = Box.createVerticalBox();
16 getContentPane().add(box);
17
18 box.add(Box.createVerticalStrut(20));
19 box.add(new JButton("button 1"));
20 box.add(Box.createGlue());
21 box.add(new JButton("button 2"));
22
23 this.pack();
24 this.setVisible(true);
25 }
26
27 public static void main(String[] args) {
28 new SampleBox();
29 }
30 }
|