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

36
LINES

< > BotCompany Repo | #1007341 // coActivateFrames - make multiple frames always go to foreground simultaneously

JavaX fragment (include)

1  
// TODO: sometimes they can't be closed anymore? (see #1014939)
2  
sclass FrameCoActivator {
3  
  long lastTime;
4  
  int timeout = 100; // prohibit endless loop
5  
  
6  
  *(final Frame... frames) {
7  
    for (final Frame f1 : frames) {
8  
      f1.addWindowListener(new WindowAdapter {
9  
        public void windowIconified(WindowEvent e) {
10  
          lastTime = sysNow();
11  
        }
12  
        
13  
        public void windowActivated(WindowEvent e) {
14  
          if (sysNow() >= lastTime+timeout) {
15  
            lastTime = sysNow();
16  
            //print(text);
17  
            for (Frame f2 : frames)
18  
              if (f2 != f1)
19  
                activateFrame(f2);
20  
            activateFrame(f1);
21  
          }
22  
        }
23  
      });
24  
    }
25  
  }
26  
}
27  
28  
static Frame[] coActivateFrames(Frame... frames) {
29  
  new FrameCoActivator(frames);
30  
  ret frames;
31  
}
32  
33  
static <A extends Frame> L<A> coActivateFrames(L<A> frames) {
34  
  coActivateFrames(toArray(frames, Frame.class));
35  
  ret frames;
36  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007341
Snippet name: coActivateFrames - make multiple frames always go to foreground simultaneously
Eternal ID of this version: #1007341/13
Text MD5: 71f6067923d2a14ff3f6582df689e7a4
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-06 19:28:52
Source code size: 967 bytes / 36 lines
Pitched / IR pitched: No / No
Views / Downloads: 574 / 618
Version history: 12 change(s)
Referenced in: [show references]