Java Code Examples for javax.swing.JInternalFrame#getWidth()
The following examples show how to use
javax.swing.JInternalFrame#getWidth() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SeaGlassDesktopPaneUI.java From seaglass with Apache License 2.0 | 8 votes |
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { c = c.getParent(); if (c != null) { c.add(f); if (f.isMaximum()) { int w = c.getWidth(); int h = c.getHeight() - taskBar.getHeight(); if (f.getWidth() != w || f.getHeight() != h) { setBoundsForFrame(f, 0, 0, w, h); } } if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } } }
Example 2
Source File: JInternalFrameMoveOverlapping.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected void prepareControls() { JDesktopPane desktopPane = new JDesktopPane(); JInternalFrame bottomFrame = new JInternalFrame("bottom frame", false, false, false, false); bottomFrame.setSize(220, 220); super.propagateAWTControls(bottomFrame); desktopPane.add(bottomFrame); bottomFrame.setVisible(true); JInternalFrame topFrame = new JInternalFrame("top frame", false, false, false, false); topFrame.setSize(200, 200); topFrame.add(new JButton("LW Button") { { addMouseListener(new MouseAdapter() { @Override public void mouseClicked(MouseEvent e) { lwClicked = true; } }); } }); desktopPane.add(topFrame); topFrame.setVisible(true); JFrame frame = new JFrame("Test Window"); frame.setSize(300, 300); frame.setContentPane(desktopPane); frame.setVisible(true); locTopFrame = topFrame.getLocationOnScreen(); locTarget = new Point(locTopFrame.x + bottomFrame.getWidth() / 2, locTopFrame.y + bottomFrame.getHeight()/2); }
Example 3
Source File: OOODesktopManager.java From noa-libre with GNU Lesser General Public License v2.1 | 5 votes |
public void deiconifyFrame(JInternalFrame f) { JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); Container c = desktopIcon.getParent(); if (c != null) { f.setBounds(oldBounds.remove(f)); //XXX //c.add(f); //XXX // If the frame is to be restored to a maximized state make // sure it still fills the whole desktop. if (f.isMaximum()) { Rectangle desktopBounds = c.getBounds(); if (f.getWidth() != desktopBounds.width || f.getHeight() != desktopBounds.height) { setBoundsForFrame(f, 0, 0, desktopBounds.width, desktopBounds.height); } } removeIconFor(f); if (f.isSelected()) { f.moveToFront(); } else { try { f.setSelected(true); } catch (PropertyVetoException e2) { } } } }
Example 4
Source File: Canvas.java From freecol with GNU General Public License v2.0 | 4 votes |
/** * Adds a component on this Canvas inside a frame. * * @param comp The component to add to the canvas. * @param toolBox Should be set to true if the resulting frame is * used as a toolbox (that is: it should not be counted as a * frame). * @param popupPosition A preferred {@code PopupPosition}. * @param resizable Whether this component can be resized. * @return The {@code JInternalFrame} that was created and added. */ private JInternalFrame addAsFrame(JComponent comp, boolean toolBox, PopupPosition popupPosition, boolean resizable) { final int FRAME_EMPTY_SPACE = 60; final JInternalFrame f = (toolBox) ? new ToolBoxFrame() : new JInternalFrame(); Container con = f.getContentPane(); if (con instanceof JComponent) { JComponent c = (JComponent)con; c.setOpaque(false); c.setBorder(null); } if (comp.getBorder() != null) { if (comp.getBorder() instanceof EmptyBorder) { f.setBorder(Utility.blankBorder(10, 10, 10, 10)); } else { f.setBorder(comp.getBorder()); comp.setBorder(Utility.blankBorder(5, 5, 5, 5)); } } else { f.setBorder(null); } final FrameMotionListener fml = new FrameMotionListener(f); comp.addMouseMotionListener(fml); comp.addMouseListener(fml); if (f.getUI() instanceof BasicInternalFrameUI) { BasicInternalFrameUI biu = (BasicInternalFrameUI) f.getUI(); biu.setNorthPane(null); biu.setSouthPane(null); biu.setWestPane(null); biu.setEastPane(null); } f.getContentPane().add(comp); f.setOpaque(false); f.pack(); int width = f.getWidth(); int height = f.getHeight(); if (width > getWidth() - FRAME_EMPTY_SPACE) { width = Math.min(width, getWidth()); } if (height > getHeight() - FRAME_EMPTY_SPACE) { height = Math.min(height, getHeight()); } f.setSize(width, height); Point p = chooseLocation(comp, width, height, popupPosition); f.setLocation(p); this.addToCanvas(f, MODAL_LAYER); f.setName(comp.getClass().getSimpleName()); f.setFrameIcon(null); f.setVisible(true); f.setResizable(resizable); try { f.setSelected(true); } catch (java.beans.PropertyVetoException e) {} return f; }