public void testListCoercionPropertyOnJFrame() throws Exception { if (HeadlessTestSupport.isHeadless()) return; try { JFrame bean = new JFrame(); List list = new ArrayList(); list.add(new Integer(10)); list.add(new Integer(20)); InvokerHelper.setProperty(bean, "location", list); assertEquals("Should have set a point", new Point(10, 20), bean.getLocation()); } catch (MissingMethodException e) { System.out.println("Failed with cause: " + e); e.printStackTrace(); fail("Should not have throw: " + e); } }
public Element whereShowing() { return new Element(frame.getLocation().x, frame.getLocation().y, frame.getWidth(), frame.getHeight()); } //</editor-fold>
public Point getLocation() { return frame.getLocation(); }
JFrame frame; //your frame int xAbs = frame.getLocation().x + xRel; int yAbs = frame.getLocation().y + yRel;
/** * save window position and size */ private void saveWindowRealEstate() { Dimension size = this.mainFrame.getSize(); preferences.putInt("Default window width", size.width); preferences.putInt("Default window height", size.height); Point location = this.mainFrame.getLocation(); preferences.putInt("Default window location x", location.x); preferences.putInt("Default window location y", location.y); }
public static Point centerPoint(int width, int height, JFrame frame) { Point point = null; Dimension frameSize = frame.getSize(); Point framePoint = frame.getLocation(); point = new Point(framePoint.x + (frameSize.width / 2) - (width / 2), framePoint.y + (frameSize.height / 2) - (height / 2)); return point; }
public Point getLocation() { if(useDesktop) { return jInternalFrame.getLocation(); } else { return jFrame.getLocation(); } }
private void putPreferencesLocation() { int x = frame.getLocation().x; int y = frame.getLocation().y; if(getPreferencesX() == x && getPreferencesY() == y) return; preferences.putInt(X_PREFERENCE, x); preferences.putInt(Y_PREFERENCE, y); log.info("Storing frame location as " + frame.getLocation()); String deviceId = frame.getGraphicsConfiguration().getDevice().getIDstring(); preferences.put(DEVICE_PREFERENCE, deviceId); log.info("Storing graphics device as " + deviceId); }
@Override public void mousePressed(final MouseEvent e) { Point location = smallFrame.getLocation(); point.x = e.getXOnScreen() - (int) location.getX(); point.y = e.getYOnScreen() - (int) location.getY(); } });
@Override public void mouseDragged(MouseEvent me) { SwingUtilities.invokeLater(() -> { if(!Lancador.getInstance().isMaximazed()){ JFrame frame = Lancador.getInstance().getJFrame(); frame.setLocation(frame.getLocation().x + me.getX() - pX,frame.getLocation().y + me.getY() - pY); } }); }
JFrame frame = new JFrame("Test"); frame.setLocation(100, 100); frame.setSize(500, 500); frame.setVisible(true); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); // 'Invisible' fake component for positioning JWindow c = new JWindow(); c.setSize(0, 0); c.setVisible(true); Point location = frame.getLocation(); location.translate(200, 100); c.setLocation(location); JOptionPane.showInputDialog(c,"Foo");
/** * @param parentFrame the parentFrame to set */ public void centerDialog(JFrame parentFrame) { this.setLocation( parentFrame.getLocation().x + parentFrame.getWidth() / 2 - this.getWidth() / 2, parentFrame.getLocation().y + parentFrame.getHeight() / 2 - this.getHeight() / 2); } }
@Override public void mouseDragged(MouseEvent me) { SwingUtilities.invokeLater(() -> { if(!Lancador.getInstance().isMaximazed()){ JFrame frame = Lancador.getInstance().getJFrame(); frame.setLocation(frame.getLocation().x + me.getX() - PortugolStudio.getInstancia().getTelaPrincipal().pX,frame.getLocation().y + me.getY() - PortugolStudio.getInstancia().getTelaPrincipal().pY); } }); } @Override
@Override public void mouseDragged(MouseEvent me) { SwingUtilities.invokeLater(() -> { if(!Lancador.getInstance().isMaximazed()){ JFrame frame = Lancador.getInstance().getJFrame(); frame.setLocation(frame.getLocation().x + me.getX() - pX,frame.getLocation().y + me.getY() - pY); if(Lancador.getInstance().getQtdMonitores() == 1) { Lancador.getInstance().snapToEdge(me); } } }); } });
private void setValuesFromSettings() { jWidth.setText(String.valueOf(program.getMainWindow().getFrame().getSize().width)); jHeight.setText(String.valueOf(program.getMainWindow().getFrame().getSize().height)); jX.setText(String.valueOf(fixValue(program.getMainWindow().getFrame().getLocation().x))); jY.setText(String.valueOf(fixValue(program.getMainWindow().getFrame().getLocation().y))); jMaximized.setSelected(program.getMainWindow().getFrame().getState() == JFrame.MAXIMIZED_BOTH); }
private static void saveDesktopBounds() { Point pos = desktopFrame.getLocation(); Dimension s = desktopFrame.getSize(); Rectangle r = new Rectangle(pos.x, pos.y, s.width, s.height); XJPreferences prefs = XJApplication.shared().getPreferences(); prefs.setObject(PREF_DESKTOP_BOUNDS, r); }
@Override public void mouseDragged(MouseEvent me) { SwingUtilities.invokeLater(() -> { if(!Lancador.getInstance().isMaximazed()){ JFrame frame = Lancador.getInstance().getJFrame(); frame.setLocation(frame.getLocation().x + me.getX() - PortugolStudio.getInstancia().getTelaPrincipal().pX,frame.getLocation().y + me.getY() - PortugolStudio.getInstancia().getTelaPrincipal().pY); if(Lancador.getInstance().getQtdMonitores() == 1) { Lancador.getInstance().snapToEdge(me); } } }); } });
/** * Saves the current settings to the cfg file. */ void saveSettings() { // save frame location GUIPreferences.getInstance().setWindowPosX(frame.getLocation().x); GUIPreferences.getInstance().setWindowPosY(frame.getLocation().y); GUIPreferences.getInstance().setWindowSizeWidth(frame.getSize().width); GUIPreferences.getInstance().setWindowSizeHeight(frame.getSize().height); }
/** * Writes the current configuration to disk. */ protected void writeConfig() { try { this.config.setRcCollectionsManagerJFrameSize(this.getJFrame().getSize()); this.config.setRcCollectionsManagerJFrameLocation(this.getJFrame().getLocation()); File configFile = RcFileUtils.getConfigFile(RcCollectionsManagerJPanel.CONFIG_FILE); config.writeConfiguration(configFile); } catch (Exception ex) { ex.printStackTrace(); } }
public void updateSettings() { if (Settings.get().isWindowAutoSave()) { Settings.get().setWindowMaximized(isMaximized()); if (!isMaximized()) { Settings.get().setWindowSize(jFrame.getSize()); Settings.get().setWindowLocation(jFrame.getLocation()); } } }