public class JbuttonDemo10 extends JFrame {
public static void main(String[] args) {
new JbuttonDemo10();
}
public JbuttonDemo10() {
Container container = this.getContentPane();
URL url = JbuttonDemo10.class.getResource("002.jpg");
Icon icon = new ImageIcon(url);
JButton button = new JButton();
button.setIcon(icon);
button.setToolTipText("按了药丸");
container.add(button);
this.setVisible(true);
this.setSize(500,300);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
public class JbuttonDemo1 extends JFrame {
public static void main(String[] args) {
new JbuttonDemo1();
}
public JbuttonDemo1() {
Container container = this.getContentPane();
URL url = JbuttonDemo10.class.getResource("002.jpg");
Icon icon = new ImageIcon(url);
JRadioButton radioButton = new JRadioButton("活着");
JRadioButton radioButton1 = new JRadioButton("死了");
JRadioButton radioButton2 = new JRadioButton("半条命");
ButtonGroup group = new ButtonGroup();
group.add(radioButton);
group.add(radioButton1);
group.add(radioButton2);
container.add(radioButton,BorderLayout.CENTER);
container.add(radioButton1,BorderLayout.NORTH);
container.add(radioButton2,BorderLayout.SOUTH);
this.setVisible(true);
this.setSize(500,300);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}
public class JbuttonDemo2 extends JFrame {
public static void main(String[] args) {
new JbuttonDemo2();
}
public JbuttonDemo2() {
Container container = this.getContentPane();
URL url = JbuttonDemo10.class.getResource("002.jpg");
Icon icon = new ImageIcon(url);
JCheckBox checkBox1 = new JCheckBox("checkBox1");
JCheckBox checkBox2 = new JCheckBox("checkBox2");
container.add(checkBox1,BorderLayout.NORTH);
container.add(checkBox2,BorderLayout.SOUTH);
this.setVisible(true);
this.setSize(500,300);
this.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
}
}