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);
}
}
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);
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货