编写一个Applet程序(JAVA)

来源:百度知道 编辑:UC知道 时间:2024/05/30 12:30:35
其中包括一个标签,一个文本框和一个按钮,当用户单击按钮时,程序把文本框中的内容复制到标签中

import java.awt.*;
import java.awt.event.*;

class Test
{
static Frame f= new Frame();
static Label l = new Label();
static Button b = new Button("按钮");
static TextArea tb = new TextArea();

public static void main(String[] args) {
f.setSize(300,300);
f.setLocation(100,100);
f.setVisible(true);
f.add(l,"North");
f.add(tb,"Center");
f.add(b,"South");
l.setText("标签");
tb.setText("文本框");
l.setVisible(true);
b.setVisible(true);
tb.setVisible(true);
f.pack();
f.addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){
System.exit(0);
}
});
b.addMouseListener(new MouseAdapter(){
public void mouseClicked(MouseEvent e){
l.setText(tb.getText());
}
});

}
}

//here it is<