找回密码
 入驻
搜索
查看: 131333|回复: 4

小程序一个

[复制链接]
发表于 2007-5-26 17:30:12 | 显示全部楼层 |阅读模式
import java.awt.*;
import java.awt.event.*;

public class MyjavaFrame extends WindowAdapter implements ActionListener{
   Frame f;
   Button bt1,bt2,bt3;
   TextField tx1,tx2;
   Label l1,l2;
   int tag=0;
  public static void main(String args[])
  {
     new MyjavaFrame().init();
  }
  public void init()
  {
     f=new Frame("My Frame");
  
     bt1=new Button("Clear");
     bt1.addActionListener(this);
     
     bt2=new Button("Copy");
     bt2.addActionListener(this);
   
     bt3=new Button("Close");
     bt3.addActionListener(this);
     
     tx1=new TextField("",30);
     
     tx2=new TextField("",30);
  
     l1=new Label("Source");
     
     
     l2=new Label("Target");
    f.add(l1);    f.add(tx1);
    f.add(l2);    f.add(tx2);
     f.setLayout(new FlowLayout());
     
     f.add(bt1);
     f.add(bt2);
    f.add(bt3);
     
     f.addWindowListener(this);
     f.setSize(300,300);
     f.setVisible(true);
     
  }
  public void windowClosing(WindowEvent e){
  System.exit(0);
  }

  public void actionPerformed(ActionEvent e)
  {
     String s1="";
     String s2=tx1.getText();
     if(e.getActionCommand()=="Clear")
       {
       tx1.setText(s1);
       tx2.setText(s1);
      }
        else if(e.getActionCommand()=="Copy")
     tx2.setText(s2);
         else System.exit(0);
  }
        
  
}
发表于 2007-5-26 17:45:28 | 显示全部楼层
有什么作用~~~??/
回复

使用道具 举报

发表于 2007-5-26 17:49:52 | 显示全部楼层
不说什么用途  谁懂啊!!!看也只有你了……
回复

使用道具 举报

发表于 2007-5-26 17:50:19 | 显示全部楼层
new 出一个窗体,然后上面new出些乱七八糟的控件
回复

使用道具 举报

发表于 2007-5-26 18:03:20 | 显示全部楼层
完全不懂```````
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 入驻

本版积分规则

QQ|Archiver|手机版|小黑屋|思明论坛

GMT+8, 2024-9-28 17:34 , Processed in 0.010404 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表