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).

sbool activateFrame(final Component c, O... _) {
  ret swing(func -> bool {
    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()) {
      bool fullscreen = f.getExtendedState() == Frame.MAXIMIZED_BOTH;
      f.setExtendedState(JFrame.ICONIFIED);
      f.setExtendedState(fullscreen ? JFrame.MAXIMIZED_BOTH : JFrame.NORMAL);
    }
    
    f.toFront();
    true;
  });
}

download  show line numbers  debug dex   

Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, 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: 372 / 433
Version history: 17 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1007342 & http://1007342.tinybrain.de