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

1  
scope activateFrame_v3.
2  
3  
static int #delay = 100;
4  
5  
sbool activateFrame_v3(Component c, O... _) {
6  
  ret swing(-> {
7  
    Frame f = getAWTFrame(c);
8  
    if (f == null) false;
9  
    if (!f.isVisible()) f.setVisible(true);
10  
    int state = f.getState();
11  
    bool iconified = state == Frame.ICONIFIED;
12  
    optPar bool maximize;
13  
    
14  
    if (iconified)
15  
      f.setState(maximize ? Frame.MAXIMIZED_BOTH : Frame.NORMAL);
16  
    else {
17  
      f.setState(Frame.ICONIFIED);
18  
      print("Restoring frame in " + delay + " ms");
19  
      doLater(delay, r { f.setState(state) });
20  
    }
21  
22  
    f.toFront();
23  
    true;
24  
  });
25  
}

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: 163 / 236
Version history: 5 change(s)
Referenced in: [show references]