1个回答
2013-07-12
展开全部
import java.awt.*;
import java.awt.event.*;
public class TestTextField {
public static void main(String[] args) {
MyTestField mtf = new MyTestField();
}
}
class MyTestField extends Frame {
TextField tf1,tf2;
MyTestField() {
super("test");
tf1 = new TextField(10);
tf2 = new TextField(10);
Button b1 = new Button("确定");
b1.addActionListener(new Monitor());
Label lb1 = new Label("输入");
Label lb2 = new Label("输出");
add(lb1);add(tf1);add(b1);add(lb2);add(tf2);
pack();
setLayout(new FlowLayout());
setSize(200,200);
setVisible(true);
}
class Monitor implements ActionListener {
public void actionPerformed(ActionEvent e) {
tf2.setText(tf1.getText());
tf1.setText("");
}
}
}
import java.awt.event.*;
public class TestTextField {
public static void main(String[] args) {
MyTestField mtf = new MyTestField();
}
}
class MyTestField extends Frame {
TextField tf1,tf2;
MyTestField() {
super("test");
tf1 = new TextField(10);
tf2 = new TextField(10);
Button b1 = new Button("确定");
b1.addActionListener(new Monitor());
Label lb1 = new Label("输入");
Label lb2 = new Label("输出");
add(lb1);add(tf1);add(b1);add(lb2);add(tf2);
pack();
setLayout(new FlowLayout());
setSize(200,200);
setVisible(true);
}
class Monitor implements ActionListener {
public void actionPerformed(ActionEvent e) {
tf2.setText(tf1.getText());
tf1.setText("");
}
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询
广告 您可能关注的内容 |