fifthwindow.java

来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 32 行

JAVA
32
字号
import javax.swing.*;
import java.awt.event.*;
public class FifthWindow extends JFrame
{
  private JFrame mainFrame;

  public FifthWindow() // a constructor
  {
    mainFrame = new JFrame("Fifth GUI Window");

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

     // create and register the handler in one statement
    mainFrame.addWindowListener(new WinHandler()); 
  } 

     // an inner class to handle window events
   
   class WinHandler extends WindowAdapter
   {
     public void windowClosing(WindowEvent e) {System.exit(0);}
   }  // end of inner class  

  public static void main(String args[])
  {
    new FifthWindow(); 
  }
    
}  // end of GUI class

⌨️ 快捷键说明

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