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

56
LINES

< > BotCompany Repo | #1020192 // Move Module Window To Separate Desktop Pane (And Back) Spike [WORKS]

JavaX source code (Dynamic Module) [tags: use-pretranspiled] - run with: Stefan's OS

Libraryless. Click here for Pure Java version (14758L/102K).

!7

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

module SeparateDesktopPaneSpike > DynSingleFunctionWithPrintLog {
  void doIt {
    final JInternalFrame myFrame = cast dm_frame();
    if (myFrame == null) ret;
    if (getParent(myFrame) != dm_desktopPane()) ret with moveBack();
    Rectangle boundsOnScreen = boundsOnScreen(myFrame);
    final JDesktopPane desktopPane = jDesktopPane();
    autoFixDesktopPane(desktopPane);
    showFrame(dm_moduleName(), desktopPane);
    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);
      InternalFrameUI ui = myFrame.getUI();
      if (ui cast BasicInternalFrameUI) {
        ui.setNorthPane(null);
      }
    }
  }
  
  void moveBack ctex {
    final JInternalFrame myFrame = cast dm_frame();
    if (myFrame == null) ret;
    JDesktopPane desktopPane = cast getParent(myFrame);
    if (desktopPane == dm_desktopPane()) ret;
    removeFromParent(myFrame);
    myFrame.updateUI();
    myFrame.setMaximum(false);
    myFrame.setMaximizable(true);
    myFrame.setClosable(true);
    myFrame.setIconifiable(true);
    dm_desktopPane().add(myFrame);
    Rectangle bounds = rectangleFromScreenToComponent(boundsOnScreen(getFrame(desktopPane)), dm_desktopPane());
    print("Setting bounds: " + bounds);
    myFrame.setBounds(bounds);
    fixInternalFrame(myFrame);
    myFrame.toFront();
    myFrame.setSelected(true);
    print("Have bounds: " + getBounds(myFrame);
    disposeFrame(desktopPane);
    desktopPane = null;
    call(dm_getStem(this), 'enhanceFrame, myFrame); // re-add title menus
  }
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

-
Snippet ID: #1020192
Snippet name: Move Module Window To Separate Desktop Pane (And Back) Spike [WORKS]
Eternal ID of this version: #1020192/42
Text MD5: 214876ec920ec0613f6a5e297aaca247
Transpilation MD5: df94e971df11b5d75e7080d339bc3bff
Author: stefan
Category: javax / stefan's os
Type: JavaX source code (Dynamic Module)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-12-10 01:57:17
Source code size: 1985 bytes / 56 lines
Pitched / IR pitched: No / No
Views / Downloads: 370 / 714
Version history: 41 change(s)
Referenced in: