windowcloser.java

来自「拥有图形界面的」· Java 代码 · 共 65 行

JAVA
65
字号
/** * Utility class to catch window close events on a target * window and actually dispose the window. */package org.joone.edit;import java.awt.*;import java.awt.event.*;public class WindowCloser implements WindowListener {   /**    * Create an adaptor to listen for window closing events    * on the given window and actually perform the close.    */    public WindowCloser(Window w) {	this(w, false);    }   /**    * Create an adaptor to listen for window closing events    * on the given window and actually perform the close.    * If "exitOnClose" is true we do a System.exit on close.    */    public WindowCloser(Window w, boolean exitOnClose) {	this.exitOnClose = exitOnClose;	w.addWindowListener(this);    }    public void windowOpened(WindowEvent e) {    }    public void windowClosing(WindowEvent e) {	if (exitOnClose) {            System.exit(0);	}	e.getWindow().dispose();    }    public void windowClosed(WindowEvent e) {	if (exitOnClose) {            System.exit(0);	}    }    public void windowIconified(WindowEvent e) {    }    public void windowDeiconified(WindowEvent e) {    }    public void windowActivated(WindowEvent e) {    }    public void windowDeactivated(WindowEvent e) {    }    private boolean exitOnClose;}

⌨️ 快捷键说明

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