Java Code Examples for javax.swing.JFrame#getLocation()
The following examples show how to use
javax.swing.JFrame#getLocation() .
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: Framework.java From marathonv5 with Apache License 2.0 | 6 votes |
public void makeNewWindow() { JFrame frame = new MyFrame(this); numWindows++; System.out.println("Number of windows: " + numWindows); if (lastLocation != null) { // Move the window over and down 40 pixels. lastLocation.translate(40, 40); if ((lastLocation.x > maxX) || (lastLocation.y > maxY)) { lastLocation.setLocation(0, 0); } frame.setLocation(lastLocation); } else { lastLocation = frame.getLocation(); } System.out.println("Frame location: " + lastLocation); frame.setVisible(true); }
Example 2
Source File: ProgressWindow.java From pcap-burp with GNU Affero General Public License v3.0 | 6 votes |
public ProgressWindow(JFrame parent, String title, String message) { super(parent, title, true); if (parent != null) { Dimension parentSize = parent.getSize(); Point p = parent.getLocation(); setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4); } JPanel messagePane = new JPanel(); label = new JLabel(message); messagePane.add(label); getContentPane().add(messagePane); JPanel progressPane = new JPanel(); progressBar = new JProgressBar(0, 100); progressBar.setIndeterminate(true); progressBar.setPreferredSize(new Dimension(250, 20)); progressBar.setVisible(true); progressPane.add(progressBar); getContentPane().add(progressPane, BorderLayout.SOUTH); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); }
Example 3
Source File: ImportFromUrlDialog.java From zap-extensions with Apache License 2.0 | 5 votes |
public ImportFromUrlDialog(JFrame parent, ExtensionImportWSDL caller) { super(parent, Constant.messages.getString(MESSAGE_PREFIX + "actionName"), true); if (caller != null) { this.caller = caller; } if (parent != null) { Dimension parentSize = parent.getSize(); Point p = parent.getLocation(); setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4); } // set up layout setLayout(new GridBagLayout()); GridBagConstraints constraints = new GridBagConstraints(); constraints.anchor = GridBagConstraints.WEST; constraints.insets = new Insets(5, 5, 5, 5); buttonImport.addActionListener(this); // add components to the frame constraints.gridx = 0; constraints.gridy = 0; add(labelURL, constraints); constraints.gridx = 1; constraints.fill = GridBagConstraints.HORIZONTAL; constraints.weightx = 1.0; fieldURL = addContextMenu(fieldURL); add(fieldURL, constraints); constraints.gridy = 2; constraints.anchor = GridBagConstraints.CENTER; add(buttonImport, constraints); setDefaultCloseOperation(DISPOSE_ON_CLOSE); pack(); setVisible(true); }
Example 4
Source File: WindowSettingsParameter.java From mzmine2 with GNU General Public License v2.0 | 5 votes |
@Override public void componentMoved(ComponentEvent e) { if (!(e.getComponent() instanceof JFrame)) return; JFrame frame = (JFrame) e.getComponent(); int state = frame.getExtendedState(); isMaximized = ((state & Frame.MAXIMIZED_HORIZ) != 0) && ((state & Frame.MAXIMIZED_VERT) != 0); if (!isMaximized) { position = frame.getLocation(); } }
Example 5
Source File: GrammarvizGuesserDialog.java From grammarviz2_src with GNU General Public License v2.0 | 5 votes |
/** Creates the reusable dialog. */ public GrammarvizGuesserDialog(JFrame topFrame, JPanel guesserPane, UserSession session) { super(topFrame, true); if (topFrame != null) { Dimension parentSize = topFrame.getSize(); Point p = topFrame.getLocation(); setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4); } this.setTitle("Sampler interval and parameter ranges verification"); // this.session = session; this.guesserPane = (GrammarvizGuesserPane) guesserPane; MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]"); getContentPane().setLayout(mainFrameLayout); getContentPane().add(this.guesserPane, "h 200:200:,w 400:400:,growx,growy,wrap"); JPanel buttonPane = new JPanel(); JButton okButton = new JButton(OK_BUTTON_TEXT); JButton cancelButton = new JButton(CANCEL_BUTTON_TEXT); buttonPane.add(okButton); buttonPane.add(cancelButton); okButton.addActionListener(this); cancelButton.addActionListener(this); getContentPane().add(buttonPane, "wrap"); pack(); }
Example 6
Source File: GrammarvizOptionsDialog.java From grammarviz2_src with GNU General Public License v2.0 | 5 votes |
/** Creates the reusable dialog. */ public GrammarvizOptionsDialog(JFrame parentFrame, JPanel optionPanel, UserSession session) { super(parentFrame, true); if (parentFrame != null) { Dimension parentSize = parentFrame.getSize(); Point p = parentFrame.getLocation(); setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4); } this.session = session; this.optionPane = (GrammarvizOptionsPane) optionPanel; MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]"); getContentPane().setLayout(mainFrameLayout); getContentPane().add(this.optionPane, "h 200:300:,w 500:550:,growx,growy,wrap"); JPanel buttonPane = new JPanel(); JButton okButton = new JButton(OK_BUTTON_TEXT); JButton cancelButton = new JButton(CANCEL_BUTTON_TEXT); buttonPane.add(okButton); buttonPane.add(cancelButton); okButton.addActionListener(this); cancelButton.addActionListener(this); getContentPane().add(buttonPane, "wrap"); pack(); }
Example 7
Source File: ConfigManager.java From binnavi with Apache License 2.0 | 4 votes |
/** * Stores all relevant settings in the config file object and saves the config file to the disk. * * @param parent Parent window used for dialogs. */ public void saveSettings(final JFrame parent) { final Point location = parent.getLocation(); final GeneralSettingsConfigItem.LastOpenWindowConfigItem window = generalSettings.getLastOpenWindow(); window.setTop((int) location.getY()); window.setLeft((int) location.getX()); window.setHeight(parent.getHeight()); window.setWidth(parent.getWidth()); generalSettings.setMaximizeWindow((parent.getExtendedState() == Frame.ICONIFIED) || (parent.getExtendedState() == Frame.MAXIMIZED_BOTH)); databases.clear(); for (final IDatabase database : CDatabaseManager.instance()) { final DatabaseConfigItem databaseConfig = new DatabaseConfigItem(); databaseConfig.setAutoConnect(database.getConfiguration().isAutoConnect()); databaseConfig.setDescription(database.getConfiguration().getDescription()); databaseConfig.setDriver(database.getConfiguration().getDriver()); databaseConfig.setPassword(database.getConfiguration().isSavePassword() ? database.getConfiguration().getPassword() : ""); databaseConfig.setSavePassword(database.getConfiguration().isSavePassword()); databaseConfig.setHost(database.getConfiguration().getHost()); databaseConfig.setName(database.getConfiguration().getName()); databaseConfig.setUser(database.getConfiguration().getUser()); databaseConfig.setIdentity(database.getConfiguration().getIdentity()); databases.add(databaseConfig); } try { write(); } catch (final FileWriteException e) { CUtilityFunctions.logException(e); final String innerMessage = "E00150: " + "Could not write configuration file"; final String innerDescription = CUtilityFunctions.createDescription( "The configuration file where the settings are stored could not be written.", new String[] {"There was a problem writing the file. Please see the stacktrace for more " + "information."}, new String[] {"The active configuration was not saved and will be lost."}); NaviErrorDialog.show(parent, innerMessage, innerDescription, e); } }
Example 8
Source File: AboutGrammarVizDialog.java From grammarviz2_src with GNU General Public License v2.0 | 4 votes |
public AboutGrammarVizDialog(JFrame parentFrame) { super(parentFrame, true); if (parentFrame != null) { Dimension parentSize = parentFrame.getSize(); Point p = parentFrame.getLocation(); setLocation(p.x + parentSize.width / 4, p.y + parentSize.height / 4); } JEditorPane aboutTextPane = new JEditorPane(); aboutTextPane.setEditable(false); java.net.URL helpURL = AboutGrammarVizDialog.class.getResource("/AboutText.html"); if (helpURL != null) { try { aboutTextPane.setPage(helpURL); } catch (IOException e) { System.err.println("Attempted to read a bad URL: " + helpURL); } } else { System.err.println("Couldn't find file: AboutText.html"); } // Put the editor pane in a scroll pane. JScrollPane editorScrollPane = new JScrollPane(aboutTextPane); editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS); MigLayout mainFrameLayout = new MigLayout("fill", "[grow,center]", "[grow]5[]"); getContentPane().setLayout(mainFrameLayout); getContentPane().add(editorScrollPane, "h 200:300:,w 400:500:,growx,growy,wrap"); JPanel buttonPane = new JPanel(); JButton okButton = new JButton(OK_BUTTON_TEXT); buttonPane.add(okButton); okButton.addActionListener(this); getContentPane().add(buttonPane, "wrap"); pack(); setVisible(true); }