JAVA图形程序·
来源:百度知道 编辑:UC知道 时间:2024/05/18 17:59:13
最好是application··
import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JTextArea;
public class CopyContentToAnother extends JFrame implements ActionListener{
JButton button;
JTextArea jtx,jtx2;
Container c;
JPanel p;
public CopyContentToAnother(){
c=this.getContentPane();
p= new JPanel();
jtx = new JTextArea(12,12);
jtx2 = new JTextArea(12,12);
button = new JButton("确定");
button.addActionListener(this);
p.add(jtx);
p.add(jtx2);
p.add(button);
this.add(p);
this.setSize(500, 400);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource() == button){
jtx2.setText(jtx.getText());
jtx.setT