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.

1  
sbool activateFrame_v2(Component c, O... _) {
2  
  ret swing(-> {
3  
    Frame f = getAWTFrame(c);
4  
    if (f == null) false;
5  
    if (!f.isVisible()) f.setVisible(true);
6  
    bool windowsHack = optPar windowsHack(_, true);
7  
    bool iconified = f.getState() == Frame.ICONIFIED;
8  
    optPar bool maximize;
9  
    if (iconified)
10  
      f.setState(maximize ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);
11  
      
12  
    // My glorious Windows hack
13  
    // See: https://stackoverflow.com/questions/309023/how-to-bring-a-window-to-the-front
14  
    if (windowsHack && !iconified && (isWindows() || isLinux())) {
15  
      bool fullscreen = f.getExtendedState() == Frame.MAXIMIZED_BOTH;
16  
      f.setExtendedState(JFrame.ICONIFIED);
17  
      f.setExtendedState(fullscreen ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
18  
    }
19  
    
20  
    f.toFront();
21  
    true;
22  
  });
23  
}

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: 212 / 248
Version history: 1 change(s)
Referenced in: [show references]