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

30
LINES

< > TinyBrain | #1007341 - coActivateFrames - make two frames always go to foreground simultaneously

JavaX fragment (include)

sclass FrameCoActivator {
  long lastTime;
  int timeout = 100; // prohibit endless loop
  
  *(JFrame f1, JFrame f2) {
    link(f1, f2, "zoom");
    link(f2, f1, "boom.");
  }
  
  void link(final JFrame f1, final JFrame f2, fS text) {
    f1.addWindowListener(new WindowAdapter {
      public void windowIconified(WindowEvent e) {
        lastTime = sysNow();
      }
      
      public void windowActivated(WindowEvent e) {
        if (sysNow() >= lastTime+timeout) {
          lastTime = sysNow();
          //print(text);
          activateFrame(f2);
          activateFrame(f1);
        }
      }
    });
  }
}

svoid coActivateFrames(JFrame f1, JFrame f2) {
  new FrameCoActivator(f1, f2);
}

download  show line numbers  debug dex   

Travelled to 1 computer(s): tvejysmllsmz

No comments. add comment

Snippet ID: #1007341
Snippet name: coActivateFrames - make two frames always go to foreground simultaneously
Eternal ID of this version: #1007341/5
Text MD5: c1bb40ea9c20d59b3176e37d677becd3
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-17 02:39:49
Source code size: 728 bytes / 30 lines
Pitched / IR pitched: No / No
Views / Downloads: 23 / 4
Version history: 4 change(s)
Referenced in: [show]