thirdwindow.java
来自「《A first book of java》by Gary J.Bronson 」· Java 代码 · 共 37 行
JAVA
37 行
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 + =
减小字号Ctrl + -
显示快捷键?