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

📄 windows.java

📁 java程序设计 清华出版社 孙燮华老师编写的程序源代码
💻 JAVA
字号:
//windows.java
import java.awt.*;
import java.awt.event.*;

public class windows extends Frame implements ActionListener{
  Button button1,button2;
  demoframe window1;

  public windows(String s){
    super(s);
    setLayout(new GridLayout(1,2));
    button1=new Button("Show window");
    button2=new Button("Hide window");
    button1.addActionListener(this);
    button2.addActionListener(this);
    add(button1);
    add(button2);
    window1=new demoframe("Window Demo");
    window1.setSize(200,100);
  }
                                      
  public void actionPerformed(ActionEvent e){
    if(e.getSource()==button1){
      window1.setVisible(true);
    }
    if(e.getSource()==button2){
      //window1.setVisible(false);
      window1.dispose();
    }
  }
  public static void main(String args[]){
    windows myWindows=new windows("My first windows");
    myWindows.setSize(250,100);
    myWindows.show();
  }
}

class demoframe extends Frame{
  Label label1;
  demoframe(String title){
    super(title);
    setLayout(new GridLayout(1,1));
    label1=new Label("Hello from Java!");
    add(label1);
  }
}

⌨️ 快捷键说明

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