public static void main(String args[]) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); JDesktopPane desktopPane = new JDesktopPane(); DesktopManager dm = new MageDesktopManager(); desktopPane.setDesktopManager(dm); JInternalFrame internalFrame = new JInternalFrame("Test Internal Frame", true, false, true, true); internalFrame.setSize(200, 150); internalFrame.setVisible(true); desktopPane.add(internalFrame); frame.add(desktopPane, BorderLayout.CENTER); frame.setSize(800, 600); frame.setVisible(true); }); } }
public void setSize(Dimension size) { if(useDesktop) { jInternalFrame.setSize(size); } else { jFrame.setSize(size); } }
public void setSize(int dx, int dy) { if(useDesktop) { jInternalFrame.setSize(dx, dy); } else { jFrame.setSize(dx, dy); } }
private void ensureMinWidthAndHight(JInternalFrame frame, int minWidth, int minHeight) { final Dimension frameSize = frame.getSize(); final int correctedWidth = Math.max(frameSize.width, minWidth); final int correctedHeight = Math.max(frameSize.height, minHeight); frame.setSize(new Dimension(correctedWidth, correctedHeight)); }
public void moveFrame() { JInternalFrame selectedFrame = desktopPane.getSelectedFrame(); Dimension currentSize = selectedFrame.getSize(); try { selectedFrame.setMaximum(false); } catch (PropertyVetoException ex) { ex.printStackTrace(); } selectedFrame.setSize(currentSize); desktopPane.remove(selectedFrame); desktopPane.repaint(); secondFrame.addInternalFrame(selectedFrame); }
private void recalculateDDLFrameSize(JInternalFrame ddlFrame, JTextPane txtDDL, String[] lines) { FontMetrics fm = txtDDL.getFontMetrics(txtDDL.getFont()); int txtHeight = fm.getHeight() * lines.length; int txtWidht = 0; for (int i = 0; i < lines.length; i++) { txtWidht = Math.max(txtWidht, fm.stringWidth(lines[i])); } BasicInternalFrameUI ui = (BasicInternalFrameUI) ddlFrame.getUI(); int titleHeight = ui.getNorthPane().getHeight(); ddlFrame.setSize(txtWidht + 20, txtHeight + titleHeight + 20); }
public void setSize(int width, int height) { Dimension old = internalFrame.getSize(); Dimension size = new Dimension(width, height); if (old.equals(size)) return; internalFrame.setSize(size); firePropertyChangeEvent("size", old, size); }
@Override public void setSize(int width, int height) { Point loc = getLocation(); int locX = loc.x; int locY = loc.y; Dimension desktopSize = ImageArea.getSize(); int maxWidth = Math.max(0, desktopSize.width - 20 - locX); int maxHeight = Math.max(0, desktopSize.height - 40 - locY); if (width > maxWidth) { width = maxWidth; height += 15; // correction for the horizontal scrollbar } if (height > maxHeight) { height = maxHeight; width += 15; // correction for the vertical scrollbar if (width > maxWidth) { // check again width = maxWidth; } } super.setSize(width + NIMBUS_HORIZONTAL_ADJUSTMENT, height + NIMBUS_VERTICAL_ADJUSTMENT); }
JInternalFrame iframe = new JInternalFrame("Title", true, true, true, true); iframe.setSize(180, 150); iframe.setVisible(true); iframe.getContentPane().add(new JScrollPane(new JTextArea("TestText",20,20))); JDesktopPane desktop = new JDesktopPane(); desktop.add(iframe);
private void beforeAdd(JInternalFrame child) { if (!GUIUtils.isToolWindow(child)) { Dimension cs = getSize(); // Cast to int required as Dimension::setSize(double,double) // doesn't appear to do anything in JDK1.2.2. cs.setSize((int) (cs.width * 0.8d), (int) (cs.height * 0.8d)); child.setSize(cs); } }
private void beforeAdd(JInternalFrame child) { if (!GUIUtils.isToolWindow(child)) { Dimension cs = getSize(); // Cast to int required as Dimension::setSize(double,double) // doesn't appear to do anything in JDK1.2.2. cs.setSize((int) (cs.width * 0.8d), (int) (cs.height * 0.8d)); child.setSize(cs); } }
public static void addOnScreen(JInternalFrame inFrame, String title) { //border for the internal frame javax.swing.plaf.InternalFrameUI ifu = inFrame.getUI(); ((javax.swing.plaf.basic.BasicInternalFrameUI) ifu).setNorthPane(null); Border b1 = new LineBorder(new Color(114, 139, 173), 3, true) { }; tabbedPane.setBounds(0, 0, jDesktopPane1.getWidth(), jDesktopPane1.getHeight()); inFrame.setLocation(0, 0); inFrame.setSize(jDesktopPane1.getWidth(), jDesktopPane1.getHeight()); inFrame.setBorder(b1); JPanel jp = new JPanel(); jp.setLayout(new GridLayout()); jp.setOpaque(true); jp.add(inFrame); tabbedPane.addTab(title, jp); tabbedPane.setSelectedComponent(jp); inFrame.requestFocusInWindow(); inFrame.setVisible(true); tabbedPane.setVisible(true); }
public Demo() { JFrame frame = new JFrame(); frame.setSize(300,300); JDesktopPane df = new JDesktopPane(); DesktopManager dm = df.getDesktopManager(); df.setDesktopManager(new DefaultDesktopManager(){ public void dragFrame(JComponent f, int newX, int newY) { super.dragFrame(f, newX, 5); } }); JInternalFrame jif = new JInternalFrame("test "); jif.setLocation(5, 5); jif.setSize(150,100); jif.setVisible(true); df.add(jif); frame.setContentPane(df); frame.setVisible(true); }
public void run() { JDesktopPane desktopPane = new JDesktopPane(); JInternalFrame intFrame = new JInternalFrame( "JInternalFrame demo"); intFrame.setMaximizable(true); intFrame.setIconifiable(true); intFrame.setResizable(true); intFrame.setClosable(true); intFrame.setDefaultCloseOperation(JInternalFrame.DISPOSE_ON_CLOSE); intFrame.setSize(320, 240); // intFrame.pack(); intFrame.setVisible(true); desktopPane.add(intFrame); JFrame frame = new JFrame(); frame.add(desktopPane); frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); frame.setSize(640, 480); // frame.pack(); frame.setVisible(true); } });
/** * Constructor for the InternalTest object */ InternalTest() { setLayout(new BorderLayout()); JDesktopPane desk = new JDesktopPane(); add("Center", new JScrollPane(desk)); desk.putClientProperty("JDesktopPane.backgroundEnabled", Boolean.TRUE); JInternalFrame frame = new JInternalFrame("A Frame", true, true, true, true); frame.getContentPane().add(new JButton("Ola")); frame.setVisible(true); frame.setSize(200, 100); desk.add(frame); frame = new JInternalFrame("An other Frame", true, true, true, true); frame.getContentPane().add(new JButton("Hello")); frame.setMaximizable(false); frame.setVisible(true); frame.setSize(200, 200); frame.setLocation(50, 50); desk.add(frame); } }
private void restoreDesktopState() { final List<NetworkFrame> frames = session.getSessionState() .getDesktop().getNetworkFrames().getNetworkFrame(); final Map<String, NetworkFrame> frameMap = new HashMap<String, NetworkFrame>(); for (NetworkFrame netFrame : frames) frameMap.put(netFrame.getFrameID(), netFrame); Component[] desktopFrames = Cytoscape.getDesktop() .getNetworkViewManager().getDesktopPane().getComponents(); for (int i = 0; i < desktopFrames.length; i++) { Component cmp; cmp = desktopFrames[i]; if (cmp instanceof JInternalFrame) { JInternalFrame frame = (JInternalFrame) cmp; NetworkFrame nFrame = frameMap.get(frame.getTitle()); if (nFrame != null) { frame.setSize(nFrame.getWidth().intValue(), nFrame .getHeight().intValue()); frame.setLocation(nFrame.getX().intValue(), nFrame.getY() .intValue()); } } } }
public class InternalFrameTest extends JFrame { public InternalFrameTest() { JDesktopPane desktop = new JDesktopPane(); JInternalFrame frame = new JInternalFrame("AHHHH!!!!", true); frame.setSize(300, 300); frame.setVisible(true); frame.setOpaque(false); desktop.add(frame); setContentPane(desktop); setSize(600, 600); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); setVisible(true); } public static void main(String[] args) { try { UIManager.setLookAndFeel(NimbusLookAndFeel.class.getName()); } catch (ClassNotFoundException|InstantiationException |IllegalAccessException|UnsupportedLookAndFeelException e) { e.printStackTrace(); } UIManager.put("InternalFrame:InternalFrameTitlePane[Enabled].textForeground", Color.RED); new InternalFrameTest(); } }
/** * Cascade all internal frames, un-iconfying any minimized first */ public void cascadeFrames() { restoreFrames(); int x = 0; int y = 0; JInternalFrame allFrames[] = getAllFrames(); manager.setNormalSize(); int frameHeight = getBounds().height - 5 - allFrames.length * FRAME_OFFSET; int frameWidth = getBounds().width - 5 - allFrames.length * FRAME_OFFSET; for (int i = allFrames.length - 1; i >= 0; i--) { allFrames[i].setSize(frameWidth, frameHeight); allFrames[i].setLocation(x, y); x = x + FRAME_OFFSET; y = y + FRAME_OFFSET; } }
public void checkInternalFrame(JInternalFrame _f) { if (!SwingUtilities.isEventDispatchThread()) throw new RuntimeException("Not in swing thread."); Dimension dd = getSize(); Point pf = _f.getLocation(); Dimension df = _f.getSize(); if (_f.isResizable()) { if (df.width > dd.width) df.width = dd.width; if (df.height > dd.height) df.height = dd.height; if (!df.equals(getSize())) _f.setSize(df); } if (pf.x + df.width > dd.width) pf.x = dd.width - df.width; if (pf.y + df.height > dd.height) pf.y = dd.height - df.height; if (pf.x < 0) pf.x = 0; if (pf.y < 0) pf.y = 0; if (isTabbed() && isPalette(_f) && (pf.x < LEFT_MARGIN + 4)) pf.x = LEFT_MARGIN + 4; if (!pf.equals(getLocation())) _f.setLocation(pf); adjustSize(); }
public void cmdToFrame(JScrollPane scrollingArea) { frame.remove(scrollingArea); JInternalFrame cmdFrame = new RegisteredJInternalFrame("Scripting", "Console", "Command console", true, false, false, true); cmdFrame.add(scrollingArea); cmdFrame.setVisible(true); cmdFrame.pack(); int height = frame.getSize().height / 4; int width = 1000; int yPosition = frame.getSize().height - height; if (height < 68) { height = 68; yPosition = 0; } if (width > frame.getSize().width) { width = frame.getSize().width; } scrollingArea.getViewport().setPreferredSize(new Dimension(width, height)); cmdFrame.setSize(width, height); cmdFrame.setLocation(-4, yPosition - 87); desktop.add(cmdFrame); }