编写一个小应用程序,在其中有一个按钮和一个文本框。单击按钮时,文本框中显示按钮上显示的字
											编写一个小应用程序,在其中有一个按钮和一个文本框。单击按钮时,文本框中显示按钮上显示的字										
					
	 2011-05-03 21:44
	    2011-05-03 21:44
   2011-05-03 21:48
	    2011-05-03 21:48
   2011-05-03 22:15
	    2011-05-03 22:15
   程序代码:
程序代码:public class Activity {
    public static void main(String args[])
    {
        new yxf();
    }
}
class yxf extends Frame implements ActionListener
{
    private Button button = null;//按钮句柄
    private TextArea textarea = null;//文本句柄
   
    yxf()
    {
        super("测试...");
        setBounds(100, 100, 300, 200);
        setBackground(Color.gray);
       
        initComponent();
       
        setVisible(true);
        validate();
    }
   
    private void initComponent()
    {
        button = new Button("嘿嘿...");
        button.addActionListener(this);
        add(button, BorderLayout.SOUTH);
       
        textarea = new TextArea();
        add(textarea, BorderLayout.CENTER);
       
        addWindowListener(new WindowAdapter()
        {
            public void windowClosing(WindowEvent event)
            {
                System.exit(0);
            }
        });
       
    }
    @Override
    public void actionPerformed(ActionEvent event) {
        // TODO Auto-generated method stub
        if (event.getSource() == button)
        {
            textarea.append(button.getLabel().toString() + "\n");
        }
    }
}										
					
	 2011-05-04 01:44
	    2011-05-04 01:44
   真棒。。。。。。
真棒。。。。。。										
					
	 2011-05-04 12:21
	    2011-05-04 12:21