(java)的一个问题

来源:百度知道 编辑:UC知道 时间:2024/09/19 15:39:56
我想实现在TextField 1 里打进字单击一下Button,打进出的字能在TextField 2里显示,而TextField 1消失了。我应该怎样写这些事件呢?
我还是给代码你好了 import java.awt.*;
import java.awt.event.*;
public class MyFirstFrame extends Frame implements ActionListener {
private Button quit =new Button("关闭");
private Button click =new Button("发送");
private TextField text=new TextField(10);
private TextField text2=new TextField(50);
private boolean secondClick =false;
public MyFirstFrame()
{
super("Test Window");
setLayout(new FlowLayout());
add(text2);
add(quit);
add(click);
add(text);
pack();
show();
quit.addActionListener(this);
click.addActionListener(this);

}
public void actionPerformed (ActionEvent e)
{
if (e.getSource()==quit)
System.exit(0);
else if (e.getSource()==click)

}

/**
* @param args
*/
public static void m

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;

class McJFrame extends Frame
{
TextField textField1,textField2;
Panel p1,p2,p3;
Button button;
McJFrame()
{ setLayout(new FlowLayout());
setBounds(300,50,500,700);
textField1 = new TextField(10);
textField2 = new TextField(10);
button = new Button("确定");
button.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
String message = textField1.getText();
textField2.setText(message);
textField1.setVisible(false);
}

});
p1= new Panel();
p2= new Panel();
p3= new Panel();
p1.add(textField1);
p2.add(textField2);
p3.add(button);
add(p1);