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

48
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
  
  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(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 {
    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);
    }
  }
}

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/15
Text MD5: 48b0dd1a97e43a8ec5126fb81dc35cba
Author: stefan
Category: javax / stefan's os
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2019-12-26 14:07:36
Source code size: 1843 bytes / 48 lines
Pitched / IR pitched: No / No
Views / Downloads: 177 / 224
Version history: 14 change(s)
Referenced in: [show references]

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