티스토리 뷰
public class BoxLayoutTest extends JFrame {
public BoxLayoutTest() {
super("Box Layout Test example");
JRadioButton r1, r2;
setLayout(new BorderLayout());
Box left = Box.createVerticalBox();
left.add(Box.createVerticalStrut(30));
ButtonGroup radioGroup = new ButtonGroup();
radioGroup.add(r1 = new JRadioButton("야구"));
left.add(r1);
left.add(Box.createVerticalStrut(30));
radioGroup.add(r2 = new JRadioButton("축구"));
left.add(r2);
JPanel leftPanel = new JPanel(new BorderLayout());
leftPanel.setBorder(new TitledBorder(new EtchedBorder(),"스포츠"));
leftPanel.add(left,BorderLayout.CENTER);
Box right = Box.createVerticalBox();
right.add(Box.createVerticalStrut(30));
right.add(new JCheckBox("C언어"));
right.add(Box.createVerticalStrut(30));
right.add(new JCheckBox("Java"));
right.add(Box.createVerticalStrut(30));
right.add(new JCheckBox("C#"));
right.add(Box.createVerticalStrut(30));
right.add(new JCheckBox("Phython"));
JPanel rightPanel = new JPanel(new BorderLayout());
rightPanel.setBorder(new TitledBorder(new EtchedBorder(),"프로그래밍 언어"));
rightPanel.add(right,BorderLayout.CENTER);
Box center = Box.createHorizontalBox();
center.add(leftPanel);
center.add(rightPanel);
add(center, BorderLayout.CENTER);
setSize(300,300);
setVisible(true);
}
public static void main(String[] args) {
// TODO Auto-generated method stub
BoxLayoutTest box = new BoxLayoutTest();
box.setDefaultCloseOperation(EXIT_ON_CLOSE);
}
}
'java,web study > 3주차 (7월 15일 ~21일)' 카테고리의 다른 글
JTable 02 (0) | 2013.07.17 |
---|---|
JTable (0) | 2013.07.17 |
JComboBox (0) | 2013.07.17 |
JTextField, JPasswordField, JTextArea (0) | 2013.07.17 |
JFrame (0) | 2013.07.17 |