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

📄 thirdwindow.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import javax.swing.*;
import java.awt.event.*;  // this is needed for the event handlers
public class ThirdWindow extends JFrame
{
  private JFrame mainFrame;

  public ThirdWindow() // a constructor
  {
    mainFrame = new JFrame("Third GUI Window");

   
    mainFrame.setSize(300,150);
    mainFrame.show();

    WinHandler handler = new WinHandler();  // Step 2 - create an event handler
    mainFrame.addWindowListener(handler);  // Step 3 - register (activate) the handler
  } 
    
  public static void main(String args[])
  {
    new ThirdWindow(); 
  }
}  // end of GUI class

  // Step 1 - define a listener class to handle window events
class WinHandler implements WindowListener
{
  public void windowClosing(WindowEvent e) {System.exit(0);}
  public void windowClosed(WindowEvent e) {}
  public void windowOpened(WindowEvent e) {}
  public void windowIconified(WindowEvent e) {}
  public void windowDeiconified(WindowEvent e) {}
  public void windowActivated(WindowEvent e) {}
  public void windowDeactivated(WindowEvent e) {}
}  // end of listener class 

⌨️ 快捷键说明

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