学习来源:日撸 Java 三百行(71-80天,BP 神经网络))_闵帆的博客-CSDN博客
GUI(Graphics User Interface),中文名称为图形用户界面,是指采用图形方式显示的计算机操作用户界面,是计算机与其使用者之间的对话接口,是计算机系统的重要组成部分。
代码说明:
- ApplicationShowdown.java 仅用于退出图形用户界面 GUI.
- 只生成了一个静态的实例对象. 构造方法是 private 的, 不允许在该类之外 new.
package machinelearning.gui;
import java.awt.event.*;
/**
* Shut down the application according to window action or button action.
* @author Rui Chen 1369097405@qq.com.
*/
public class ApplicationShutdown implements WindowListener, ActionListener {
/**
* Only one instance.
*/
public static ApplicationShutdown applicationShutdown = new ApplicationShutdown();
/**
***************************
* This constructor is private such that the only instance is generated here.
***************************
*/
private ApplicationShutdown() {
}// Of ApplicationShutdown.
/**
***************************
* Shutdown the system
***************************
*/
public void windowClosing(WindowEvent comeInWindowEvent) {
System.exit(0);
}// Of windowClosing.
public void windowActivated(WindowEvent comeInWindowEvent) {
}// Of windowActivated.
public void windowClosed(WindowEvent comeInWindowEvent) {
}// Of windowClosed.
public void windowDeactivated(WindowEvent comeInWindowEvent) {
}// Of windowDeactivated.
public void windowDeiconified(WindowEvent comeInWindowEvent) {
}// Of windowDeiconified.
public void windowIconified(WindowEvent comeInWindowEvent) {
}// Of windowIconified.
public void windowOpened(WindowEvent comeInWindowEvent) {
}// Of windowOpened.
/**
*************************
*************************
*/
public void actionPerformed(ActionEvent ee) {
System.exit(0);
}// Of actionPerformed.
}// Of class ApplicationShutdown