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

23
LINES

< > BotCompany Repo | #1007342 // activateFrame - bring frame to foreground

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

Libraryless. Click here for Pure Java version (2470L/16K).

1  
sbool activateFrame(final Component c, O... _) {
2  
  ret swing(func -> bool {
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()) {
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  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007342
Snippet name: activateFrame - bring frame to foreground
Eternal ID of this version: #1007342/18
Text MD5: 4ad01bc5ff4b011c7a22177a4470bbda
Transpilation MD5: fb9058767ae226665946eb63882d458a
Author: stefan
Category: javax / gui
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-01-23 19:45:51
Source code size: 833 bytes / 23 lines
Pitched / IR pitched: No / No
Views / Downloads: 703 / 848
Version history: 17 change(s)
Referenced in: [show references]