/* Swingサンプル */ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JButton; import javax.swing.ImageIcon; import java.awt.Container; import java.awt.BorderLayout; class SSample10_1 extends JFrame{ public static void main(String args[]){ SSample10_1 frame = new SSample10_1("タイトル"); frame.setVisible(true); } SSample10_1(String title){ setTitle(title); setBounds(100, 100, 300, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); ImageIcon normal_icon = new ImageIcon("./normal.png"); ImageIcon roll_icon = new ImageIcon("./roll.png"); ImageIcon pressed_icon = new ImageIcon("./pressed.png"); ImageIcon disabled_icon = new ImageIcon("./disabled.png"); JButton button1 = new JButton(normal_icon); JButton button2 = new JButton(normal_icon); button2.setRolloverIcon(roll_icon); button2.setPressedIcon(pressed_icon); JButton button3 = new JButton(normal_icon); button3.setDisabledIcon(disabled_icon); button3.setEnabled(false); p.add(button1); p.add(button2); p.add(button3); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.CENTER); } }