/* 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 SSample8_1 extends JFrame{ public static void main(String args[]){ SSample8_1 frame = new SSample8_1("タイトル"); frame.setVisible(true); } SSample8_1(String title){ setTitle(title); setBounds(100, 100, 300, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); ImageIcon icon1 = new ImageIcon("./board.png"); JButton button1 = new JButton(icon1); ImageIcon icon2 = new ImageIcon("./hasami.png"); JButton button2 = new JButton("hasami", icon2); JButton button3 = new JButton("dentaku"); ImageIcon icon3 = new ImageIcon("./dentaku.png"); button3.setIcon(icon3); ImageIcon icon4 = new ImageIcon("./bag.png"); JButton button4 = new JButton(icon4); button4.setText("BAG"); p.add(button1); p.add(button2); p.add(button3); p.add(button4); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.CENTER); } }