🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
~~~ package draw.a7; import java.awt.*; import java.awt.event.*; import javax.swing.*; public class Test extends JFrame { Wdmb6 mb=null; public static void main(String[] args) { Test lx=new Test(); } Test() { mb=new Wdmb6(); this.add(mb); this.addWindowListener(mb); this.setSize(400,300); this.setLocation(300,280); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); this.setVisible(true); } } class Wdmb6 extends JPanel implements WindowListener { public void paint(Graphics g) { super.paint(g); } @Override public void windowOpened(WindowEvent e) { System.out.println("窗口打开"); } public void windowClosing(WindowEvent e) { System.out.println("窗口关闭"); } public void windowClosed(WindowEvent e) { } public void windowIconified(WindowEvent e) { System.out.println("最小化"); } public void windowDeiconified(WindowEvent e) { System.out.println("从最小化变成正常"); } public void windowActivated(WindowEvent e) { System.out.println("窗口被激活"); } public void windowDeactivated(WindowEvent e) { } } ~~~