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

23
LINES

< > BotCompany Repo | #1033447 // activateFrame_v2 - bring frame to foreground [dev. - needs two clicks now on Linux Mint]

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

Transpiled version (5020L) is out of date.

sbool activateFrame_v2(Component c, O... _) {
  ret swing(-> {
    Frame f = getAWTFrame(c);
    if (f == null) false;
    if (!f.isVisible()) f.setVisible(true);
    bool windowsHack = optPar windowsHack(_, true);
    bool iconified = f.getState() == Frame.ICONIFIED;
    optPar bool maximize;
    if (iconified)
      f.setState(maximize ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);
      
    // My glorious Windows hack
    // See: https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front
    if (windowsHack && !iconified && (isWindows() || isLinux())) {
      bool fullscreen = f.getExtendedState() == Frame.MAXIMIZED_BOTH;
      f.setExtendedState(JFrame.ICONIFIED);
      f.setExtendedState(fullscreen ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
    }
    
    f.toFront();
    true;
  });
}

Author comment

Began life as a copy of #1007342

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, ekrmjmnbrukm, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1033447
Snippet name: activateFrame_v2 - bring frame to foreground [dev. - needs two clicks now on Linux Mint]
Eternal ID of this version: #1033447/2
Text MD5: 3a08553048aaff3acc631055b152cee9
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-10-28 17:41:20
Source code size: 835 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 108 / 153
Version history: 1 change(s)
Referenced in: [show references]