/* Swingサンプル */ import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JTextArea; import javax.swing.JButton; import javax.swing.JScrollPane; import java.awt.Container; import java.awt.BorderLayout; import java.awt.Dimension; import java.awt.event.ActionListener; import java.awt.event.ActionEvent; class SSample17_1 extends JFrame{ JTextArea area; public static void main(String args[]){ SSample17_1 frame = new SSample17_1("タイトル"); frame.setVisible(true); } SSample17_1(String title){ setTitle(title); setBounds(100, 100, 300, 250); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPanel p = new JPanel(); area = new JTextArea(); area.setLineWrap(true); JScrollPane scrollpane = new JScrollPane(area); scrollpane.setPreferredSize(new Dimension(270, 120)); JButton buttonCut = new JButton("CUT"); buttonCut.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent event){ area.cut(); } } ); JButton buttonCopy = new JButton("COPY"); buttonCopy.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent event){ area.copy(); } } ); JButton buttonPaste = new JButton("PASTE"); buttonPaste.addActionListener( new ActionListener(){ public void actionPerformed(ActionEvent event){ area.paste(); } } ); p.add(scrollpane); p.add(buttonCut); p.add(buttonCopy); p.add(buttonPaste); Container contentPane = getContentPane(); contentPane.add(p, BorderLayout.CENTER); } }