windoweventdemo.java

来自「《java事件处理指南》一书的代码,好东西」· Java 代码 · 共 35 行

JAVA
35
字号
import java.awt.*;import java.awt.event.*;public class WindowEventDemo extends Frame {   public WindowEventDemo()   {/*  The Frame registers a WindowListener.  */      addWindowListener(new WinAdapter());      setBounds(100, 100, 300, 200);      setVisible(true);   }   public static void main(String args[])   {      WindowEventDemo demo = new WindowEventDemo();   }}/*  This WindowListener does not need access to the private data    *//*  members of the WindowEventDemo class (if there were any), so    *//*  it can be implemented as a separate class that extends the      *//*  WindowAdapter class.  The windowClosing() method is overridden  *//*  to terminate the program if the window is closed.               */class WinAdapter extends WindowAdapter{   public void windowClosing(WindowEvent event)    {      System.exit(0);   }}

⌨️ 快捷键说明

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