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

25
LINES

< > BotCompany Repo | #1033448 // activateFrame_v3 - bring frame to foreground [iconify first, then restore, dev.]

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

Libraryless. Click here for Pure Java version (4879L/27K).

scope activateFrame_v3.

static int #delay = 100;

sbool activateFrame_v3(Component c, O... _) {
  ret swing(-> {
    Frame f = getAWTFrame(c);
    if (f == null) false;
    if (!f.isVisible()) f.setVisible(true);
    int state = f.getState();
    bool iconified = state == Frame.ICONIFIED;
    optPar bool maximize;
    
    if (iconified)
      f.setState(maximize ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);
    else {
      f.setState(Frame.ICONIFIED);
      print("Restoring frame in " + delay + " ms");
      doLater(delay, r { f.setState(state) });
    }

    f.toFront();
    true;
  });
}

Author comment

Began life as a copy of #1033447

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1033448
Snippet name: activateFrame_v3 - bring frame to foreground [iconify first, then restore, dev.]
Eternal ID of this version: #1033448/6
Text MD5: 4bd3df3b1944c4dafc7850105a647bd9
Transpilation MD5: a04f11d39d8b4f8e29c79fa7e65b8414
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:52:56
Source code size: 617 bytes / 25 lines
Pitched / IR pitched: No / No
Views / Downloads: 164 / 238
Version history: 5 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)