import java.awt.BorderLayout;
import java.awt.FlowLayout;
import java.awt.GridLayout;
import javax.swing.*;
public class ButtonEx extends JFrame {
public ButtonEx() {
JPanel pnlNorth = new JPanel(new GridLayout(0, 1));
JButton b = new JButton();
b.setText("button1");
b.setEnabled(false);
pnlNorth.add(b);
JButton b2 = new JButton();
ImageIcon icon = new ImageIcon("stop.png");
b2.setIcon(icon);
b2.setRolloverIcon(new ImageIcon("play.png"));
b2.setPressedIcon(new ImageIcon("pause.png"));
pnlNorth.add(b2);
JButton b3 = new JButton(new ImageIcon("hand.png"));
b3.setText("stop");
b3.setHorizontalTextPosition(JButton.CENTER);
b3.setVerticalTextPosition(JButton.TOP);
pnlNorth.add(b3);
JToggleButton tB = new JToggleButton("toggle button");
tB.setIcon(new ImageIcon("stop.png"));
tB.setSelectedIcon(new ImageIcon("pause.png"));
tB.setHorizontalTextPosition(JButton.CENTER);
tB.setVerticalTextPosition(JButton.TOP);
tB.setToolTipText("눌러보세요");
pnlNorth.add(tB);
JCheckBox ch1 = new JCheckBox("sleep");
ch1.setToolTipText("그만자슈 !");
JCheckBox ch2 = new JCheckBox("game", true);
JCheckBox ch3 = new JCheckBox("shopping", true);
JCheckBox ch4 = new JCheckBox("study");
JPanel pnlHobby = new JPanel(new FlowLayout(FlowLayout.LEFT));
pnlHobby.add(new JLabel("your hobby is?: "));
pnlHobby.add(ch1);
pnlHobby.add(ch2);
pnlHobby.add(ch3);
pnlHobby.add(ch4);
add(pnlNorth, BorderLayout.NORTH);
add(pnlHobby, BorderLayout.CENTER);
JRadioButton r = new JRadioButton("남자");
JRadioButton r1 = new JRadioButton("여자");
JRadioButton r2 = new JRadioButton("그 외");
r2.setEnabled(false);
ButtonGroup group = new ButtonGroup();
group.add(r);
group.add(r1);
group.add(r2);
JPanel pnlGender = new JPanel(new FlowLayout(FlowLayout.LEFT));
pnlGender.add(new JLabel("당신의 성별은?: "));
pnlGender.add(r);
pnlGender.add(r1);
pnlGender.add(r2);
add(pnlGender, BorderLayout.SOUTH);
setTitle("buttonEx");
pack();
setLocationRelativeTo(null);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
public static void main(String[] args) {
new ButtonEx();
}
}