⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 testbutton.java

📁 我在学习JAVA的讲义
💻 JAVA
字号:
import java.awt.*;
import java.awt.event.* ;
import javax.swing.*;
public class TestButton{
    protected static Button pushButton;
    protected static Button textButton;
    protected static Button endButton;
    protected static Button bButton;
    protected static TextArea ta1;
     protected static JFrame f,d;
    public static void main(String args[ ]){
	   f=new JFrame("rjjd");
	   d=new JFrame("ddddd");
	   pushButton=new Button("OK");
       textButton=new Button("text");
       endButton=new Button("End" );
       bButton=new Button("frame" );
       ta1=new TextArea("This is a new text1",3,10,3);
        pushButton.addActionListener(new ButtonHandler( ));
        endButton.addActionListener(new ButtonHandler( ));
        textButton.addActionListener(new ButtonHandler());
        bButton.addActionListener(new ButtonHandler());
        Container c =f.getContentPane();  
        c.setLayout (new FlowLayout());                
         c.add(ta1);
        c.add(pushButton);
        c.add(endButton);
        c.add(textButton);
        c.add(bButton);      
	f.addWindowListener(new WindowAdapter(){
       public void windowClosing(WindowEvent e){
           System.exit(0);
           }
    });
	f.setSize(500,100);
	d.setSize(500,100);
	f.setVisible(true) ;
	}
 }
 class ButtonHandler extends TestButton implements ActionListener{
    public void actionPerformed(ActionEvent e){
    if (e.getSource()==pushButton)
	pushButton.setVisible(false);
	if (e.getSource()==endButton)
	endButton.setEnabled(false);
	if (e.getSource()==textButton)
	ta1.setText("new text");
	if (e.getSource()==bButton)
		d.setVisible(true) ;
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -