1.å
³äºjavaççå¬å¨
å ³äºjavaççå¬å¨
1ãpublic void addWindowListener(WindowListener l)æ·»å æå®ççªå£ä¾¦å¬å¨ï¼ä»¥ä»æ¤çªå£æ¥æ¶çªå£äºä»¶ãå¦æ l 为 nullï¼åä¸æåºä»»ä½å¼å¸¸ï¼ä¸ä¸æ§è¡ä»»ä½æä½ãè¿ä¸ªæ¯APIä¸çæ¹æ³å®ä¹ï¼æ¤æ¹æ³åæ°ä¸ºæ¥å£WindowListenerï¼ä»»ä½å®ç°è¯¥æ¥å£çç±»é½å¯ä»¥ä½ä¸ºåæ°ã
2ãpublic abstract class WindowAdapter implements WindowListener,监监听燕窝正规溯源码 WindowStateListener, WindowFocusListener
æ¥æ¶çªå£äºä»¶çæ½è±¡éé å¨ç±»ãæ¤ç±»ä¸çæ¹æ³ä¸ºç©ºãæ¤ç±»åå¨çç®çæ¯æ¹ä¾¿å建侦å¬å¨å¯¹è±¡ã
æ©å±æ¤ç±»å¯å建 WindowEvent 侦å¬å¨å¹¶ä¸ºæéäºä»¶éå该æ¹æ³ãï¼å¦æè¦å®ç°
WindowListener æ¥å£ï¼åå¿ é¡»å®ä¹è¯¥æ¥å£å çæææ¹æ³ãæ¤æ½è±¡ç±»å°æææ¹æ³é½å®ä¹ä¸º
nullï¼æ以åªééå¯¹å ³å¿çäºä»¶å®ä¹æ¹æ³ãï¼
使ç¨æ©å±çç±»å¯ä»¥å建侦å¬å¨å¯¹è±¡ï¼ç¶å使ç¨çªå£ç addWindowListener
æ¹æ³å该çªå£æ³¨å侦å¬å¨ãå½éè¿æå¼ãå ³éãæ¿æ´»æåç¨ãå¾æ åæåæ¶å¾æ åèæ¹åäºçªå£ç¶ææ¶ï¼å°è°ç¨è¯¥ä¾¦å¬å¨å¯¹è±¡ä¸çç¸å ³æ¹æ³ï¼å¹¶å°
WindowEvent ä¼ éç»è¯¥æ¹æ³ã
3ãå¦æææ³å¨ä»£ç ä¸ä¸æ¬¡æ§ä½¿ç¨æ个类ï¼æ½è±¡ç±»æå ·ä½ç±»ï¼ææ¥å£ï¼å¯ä»¥ä½¿ç¨å¿åç±»çæ¹å¼ï¼è¿æ ·ä¸éèªå·±å®ä¹ä¸ä¸ªMy***ç±»ï¼ç¶åå使ç¨ï¼æ¯è¾æ¹ä¾¿ãç¨æ³å°±æ¯ç´æ¥å¨new WindowAdapter()åé¢å å ¥ç±»å®ä¹ï¼å¨å ¶ä¸å®ç°æè¦çæ¹æ³å°±å¯ä»¥äºã
å¿åç±»ä¸æ¯è¿åå¼ï¼èæ¯ç¸å½äºnew String(âhelloâ)è¿ç§çæ©å±å½¢å¼ãæè§å¾å¿åç±»çæå¤ç¨å¤å°±æ¯å çå¬å¨æ¶ã
éä¸WindowAdapteræºä»£ç ï¼
public abstract class WindowAdapterimplements WindowListener, WindowStateListener, WindowFocusListener
{
public void windowOpened(WindowEvent e) { }
public void windowClosing(WindowEvent e) { }
public void windowClosed(WindowEvent e) { }
public void windowIconified(WindowEvent e) { }
public void windowDeiconified(WindowEvent e) { }
public void windowActivated(WindowEvent e) { }
public void windowDeactivated(WindowEvent e) { }
public void windowStateChanged(WindowEvent e) { }
public void windowGainedFocus(WindowEvent e) { }
public void windowLostFocus(WindowEvent e) { }
}