请大家帮我看一下,编译时好像没有错,但是执行时却有一点问题.
import java.awt.*;
import java.awt.event.*;
class SimpleAwt extends WindowAdapter implements ActionListener
{
Frame MyFrame;
Label Source;
Label Target;
Button b1;
Button b2;
Button b3;
Panel MyPanel;
TextField TextField1;
TextField TextField2;
public static void main(String[] args)
{
SimpleAwt egSimpleAwt=new SimpleAwt();
egSimpleAwt.go();
}
void go()
{
MyFrame=new Frame( "My Frame ");
MyFrame.setSize(400,300);
MyPanel=new Panel();
MyFrame.add(MyPanel, "center ");
Source=new Label( "Source ");
Target=new Label( "Target ");
b1=new Button( "Clear ");
b2=new Button( "Copy ");
b3=new Button( "Close ");
TextField1=new TextField(20);
TextField1.setEditable(true);
TextField2=new TextField(20);
MyPanel.setLayout(new FlowLayout(FlowLayout.CENTER,5,5));
MyPanel.add(Source);
MyPanel.add(TextField1);
MyPanel.add(Target);
MyPanel.add(TextField2);
MyPanel.add(b1);
MyPanel.add(b2);
MyPanel.add(b3);
b1.addActionListener(this);
b2.addActionListener(this);
b3.addActionListener(this);
MyFrame.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
if(e.getActionCommand()== "Clear ")
{
TextField1.setText( " ");
}
if (e.getActionCommand()== "Copy ")
{
String str=TextField1.getText();
TextField2.setText(str);
}
if(e.getActionCommand()== "Close ")
{
System.exit(0);
}
}
public void WindowClosing(WindowEvent e)
{
System.exit(0);
}
}
------解决方案--------------------什么问题?
------解决方案--------------------帮忙顶,楼主把问题说出来啊。你不说我们怎么知道呢。虽然我们知道你有问题,可是你还是要说出来啊。