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

51
LINES

< > BotCompany Repo | #1020195 // stefansOS_popOutModule - move to separate JFrame

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

import javax.swing.plaf.InternalFrameUI;
import javax.swing.plaf.basic.BasicInternalFrameUI;

svoid stefansOS_popOutModule(Module m) ctex {
  final JInternalFrame myFrame = cast getPossiblyInternalFrame(m.vis);
  if (myFrame == null) ret;
  if (getParent(myFrame) != main.desktop) ret; // popped out already
  Rectangle boundsOnScreen = boundsOnScreen(myFrame);
  bool alwaysOnTop ifndef PreV7 = m.hasFlag(m.ALWAYSONTOPWHENPOPPEDOUT) endifndef;
  
  // make a new frame with a new DesktopPane
  // (a little trick so we can keep using JInternalFrame)
  
  JDesktopPane desktopPane = jDesktopPane();
  autoFixDesktopPane(desktopPane);
  showFrame(m.moduleName(), desktopPane);
  JFrame frame = getFrame(desktopPane);
  
  // title popup menu items
  
  if (!frameTitlePopupMenuItems(frame,
    "Pop Back In", r { stefansOS_popInModule(m) },
     jCheckBoxMenuItem("Always On Top", alwaysOnTop, r { toggleAlwaysOnTop(frame) }))) // TODO: don't use toggle, use set instead
    // can't add title menu - add button instead
    replaceComponent(desktopPane, func(JComponent dp) -> Component {
      withRightAlignedButtons_marginAttachedToCenter(dp,
        onChange(jCheckBox("Always On Top", alwaysOnTop), r { toggleAlwaysOnTop(frame) }),
        "Pop Back In", r { stefansOS_popInModule(m) }) });
        
  // position, listeners, flags, show

  setFrameBounds(desktopPane, boundsOnScreen);
  swing(r {
    removeFromParent(myFrame);
    onResizeAndNow(desktopPane, r {
      myFrame.setBounds(0, 0, desktopPane.getWidth(), desktopPane.getHeight())
    });
    desktopPane.add(myFrame);
    myFrame.setMaximum(true);
    myFrame.setMaximizable(false);
    myFrame.setClosable(false);
    myFrame.setIconifiable(false);
    frame.setAlwaysOnTop(alwaysOnTop);
    InternalFrameUI ui = myFrame.getUI();
    if (ui cast BasicInternalFrameUI)
      ui.setNorthPane(null);
    
    cset(m, poppedOut := true);
    vmBus_send modulePoppedOut(m, myFrame);
  });
}

download  show line numbers  debug dex  old transpilations   

Travelled to 9 computer(s): bhatertpkbcr, cfunsshuasjs, gwrvuhgaqvyk, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1020195
Snippet name: stefansOS_popOutModule - move to separate JFrame
Eternal ID of this version: #1020195/20
Text MD5: ae3e47b55d4b694fcd78093becd93dea
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-03-05 13:14:38
Source code size: 2004 bytes / 51 lines
Pitched / IR pitched: No / No
Views / Downloads: 315 / 376
Version history: 19 change(s)
Referenced in: #1006654 - Standard functions list 2 (LIVE, continuation of #761)
#1020196 - stefansOS_popInModule - move to main desktop again
#1025314 - stefansOS_moduleIsPoppedOut - is it in separate JFrame