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.setText("");
}
}
public static void main(String args[]){
CopyContentToAnother m =new CopyContentToAnother();
}
}
上面已经回答了
编译已经通过,运行正确,如果还有问题,请留言
main方法有,在最下面
保存文件的要求没注意。。如果可以,留言答复你吧,这样写很慢。。
存入文件是一个很简单的流操作。
◆◆
评论读取中....
请登录后再发表评论!
◆◆
修改失败,请稍后尝试