Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1003983 // disposeWindowOnClick - reacts to click in any point in the window

JavaX fragment (include) [tags: use-pretranspiled]

Transpiled version (45L) is out of date.

// Window must be made visible before calling this.
static void disposeWindowOnClick(final Window window) {
  AWTEventListener l = new AWTEventListener {
    public void eventDispatched(AWTEvent evt) {
      if (!window.isVisible()) {
        //print("disposeWindowOnClick: Forgetting listener");
        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
        ret;
      }
        
      if (!evt instanceof MouseEvent) ret;
      O source = evt.getSource();
      if (source == window && evt.getID() == MouseEvent.MOUSE_PRESSED) {
        Toolkit.getDefaultToolkit().removeAWTEventListener(this);
        window.dispose();
      }
    }
  };
  Toolkit.getDefaultToolkit().addAWTEventListener(l, AWTEvent.MOUSE_EVENT_MASK);
}

download  show line numbers  debug dex  old transpilations   

Travelled to 15 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1003983
Snippet name: disposeWindowOnClick - reacts to click in any point in the window
Eternal ID of this version: #1003983/3
Text MD5: 3f1ae7075cb518ad4257465806b3a2f1
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-01-15 03:47:59
Source code size: 755 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 693 / 697
Version history: 2 change(s)
Referenced in: [show references]