按clear按钮清空两个文本框的内容,按copy按钮时将Source文本框的内容复制到Target文本框,按close按钮结束程序的运行
`
package p1;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
//import org.omg.CORBA.PUBLIC_MEMBER;
public class CopyText extends WindowAdapter implements ActionListener
{
JFrame f;
JButton bClear,bCopy,bClose;//定义3个按钮
JLabel lsource,lTarget,lSpace1,lspace2;//定义两个标签及两个占位用空标签JTextField tfs,tft;//定义两个文本组件String ad="How are you!";public static void main(String[] args) {CopyText be=new CopyText();be.go();}public void go(){f=new JFrame("My JFrame");//定义框架f.setLayout(new GridLayout(6, 1, 10,10));//设置布局管理器f.setSize(350, 250);//设置框架的尺寸lsource=new JLabel("Source");//创建两个标签lTarget=new JLabel("Target");lSpace1=new JLabel();//创建两个占位空标签lspace2=new JLabel();tfs=new JTextField(ad,15);//创建两个文本组件tft
按clear按钮清空两个文本框的内容 按copy按钮时将Source文本框的内容复制到Target文本框 按close按钮结束程序的运行
如果觉得《按clear按钮清空两个文本框的内容 按copy按钮时将Source文本框的内容复制到Target文》对你有帮助,请点赞、收藏,并留下你的观点哦!