Java Code Examples for javax.swing.JInternalFrame#setLocation()
The following examples show how to use
javax.swing.JInternalFrame#setLocation() .
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: FrmSimulator.java From drmips with GNU General Public License v3.0 | 6 votes |
/** * Restores the specified frame's bounds from the preferences. * @param prefPrefix The prefix of the preference. * @param frame The frame. */ private void restoreFrameBounds(String prefPrefix, JInternalFrame frame) { frame.setLocation(DrMIPS.prefs.getInt(prefPrefix + "_x", 0), DrMIPS.prefs.getInt(prefPrefix + "_y", 0)); int w = DrMIPS.prefs.getInt(prefPrefix + "_w", -1); int h = DrMIPS.prefs.getInt(prefPrefix + "_h", -1); if(w > 0 && h > 0) frame.setSize(w, h); else frame.pack(); try { if(DrMIPS.prefs.getBoolean(prefPrefix + "_max", false)) frame.setMaximum(true); if(DrMIPS.prefs.getBoolean(prefPrefix + "_min", false)) frame.setIcon(true); } catch(PropertyVetoException ex) { LOG.log(Level.WARNING, "failed to maximize/minimize an internal frame"); } }
Example 2
Source File: TestViewer.java From sis with Apache License 2.0 | 6 votes |
/** * Creates and shows a new internal frame for the given image. */ private void addImage(final RenderedImage image, final String title) { final JInternalFrame internal = new JInternalFrame(title, true, true); internal.add(new ImagePanel(image)); internal.pack(); internal.show(); desktop.add(internal); if (location > min(desktop.getWidth() - internal.getWidth(), desktop.getHeight() - internal.getHeight())) { location = 0; } internal.setLocation(location, location); location += 30; internal.toFront(); }
Example 3
Source File: Canvas.java From freecol with GNU General Public License v2.0 | 5 votes |
/** * Display the map editor transform panel. */ public void showMapEditorTransformPanel() { MapEditorTransformPanel panel = new MapEditorTransformPanel(freeColClient); JInternalFrame f = addAsFrame(panel, true, PopupPosition.CENTERED, false); f.setLocation(f.getX(), 50); repaint(); }
Example 4
Source File: MarqueeBanner.java From mars-sim with GNU General Public License v3.0 | 5 votes |
public void centerLocation(JInternalFrame jif) { Dimension desktopSize = desktop.getSize(); Dimension jInternalFrameSize = jif.getSize(); int width = (desktopSize.width - jInternalFrameSize.width) / 2; int height = (desktopSize.height - jInternalFrameSize.height) / 2; jif.setLocation(width, height); jif.setVisible(true); }
Example 5
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; }