List of usage examples for javax.swing JDialog setLocation
@Override public void setLocation(Point p)
The method changes the geometry-related data.
From source file:org.accada.reader.hal.impl.sim.multi.GraphicSimulatorServer.java
/** * creates the help menu item//www . ja va2 s.c o m * * @return help menu */ private JMenu getHelpMenu() { JMenu helpMenu = new JMenu(guiText.getString("HelpMenuItem")); // about JMenuItem aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(guiText.getString("AboutMenuItem")); aboutMenuItem.addMouseListener(new MouseAdapter() { public void mouseReleased(MouseEvent e) { JDialog aboutDialog = new JDialog(GraphicSimulatorServer.this, guiText.getString("AboutDialogTitle"), true); Point pos = new Point(); pos.x = jLayeredPane.getLocationOnScreen().x + (jLayeredPane.getWidth() - getProperty("DialogWindowWidth")) / 2; pos.y = jLayeredPane.getLocationOnScreen().y + (jLayeredPane.getHeight() - getProperty("DialogWindowHeight")) / 2; aboutDialog.setLocation(pos); aboutDialog.setSize(getProperty("DialogWindowWidth"), getProperty("DialogWindowHeight")); aboutDialog.setTitle(guiText.getString("AboutDialogTitle")); JLabel text = new JLabel(guiText.getString("AboutDialogContent")); text.setHorizontalAlignment(JLabel.CENTER); aboutDialog.add(text); aboutDialog.setVisible(true); } }); helpMenu.add(aboutMenuItem); return helpMenu; }
From source file:org.executequery.components.FileChooserDialog.java
protected JDialog createDialog(Component parent) throws HeadlessException { Frame frame = parent instanceof Frame ? (Frame) parent : (Frame) SwingUtilities.getAncestorOfClass(Frame.class, parent); String title = getUI().getDialogTitle(this); JDialog dialog = new JDialog(frame, title, true); Container contentPane = dialog.getContentPane(); contentPane.setLayout(new BorderLayout()); contentPane.add(this, BorderLayout.CENTER); setPreferredSize(new Dimension(700, getPreferredSize().height)); // add any custom panel if (customPanel != null) { contentPane.add(customPanel, BorderLayout.SOUTH); }/* w w w .ja va 2 s . c om*/ if (JDialog.isDefaultLookAndFeelDecorated()) { boolean supportsWindowDecorations = UIManager.getLookAndFeel().getSupportsWindowDecorations(); if (supportsWindowDecorations) { dialog.getRootPane().setWindowDecorationStyle(JRootPane.FILE_CHOOSER_DIALOG); } } setFileView(new DefaultFileView()); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); return dialog; }
From source file:org.executequery.gui.browser.SSHTunnelConnectionPanel.java
public boolean canConnect() { if (useSshCheckbox.isSelected()) { if (!hasValue(userNameField)) { GUIUtilities//from w ww . jav a 2s .com .displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH user name"); return false; } if (!hasValue(portField)) { GUIUtilities.displayErrorMessage("You have selected SSH Tunnel but have not provided an SSH port"); return false; } if (!hasValue(passwordField)) { final JPasswordField field = WidgetFactory.createPasswordField(); JOptionPane optionPane = new JOptionPane(field, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = optionPane.createDialog("Enter SSH password"); dialog.addWindowFocusListener(new WindowAdapter() { @Override public void windowGainedFocus(WindowEvent e) { field.requestFocusInWindow(); } }); dialog.pack(); dialog.setLocation(GUIUtilities.getLocationForDialog(dialog.getSize())); dialog.setVisible(true); dialog.dispose(); int result = Integer.parseInt(optionPane.getValue().toString()); if (result == JOptionPane.OK_OPTION) { String password = MiscUtils.charsToString(field.getPassword()); if (StringUtils.isNotBlank(password)) { passwordField.setText(password); return true; } else { GUIUtilities.displayErrorMessage( "You have selected SSH Tunnel but have not provided an SSH password"); // send back here and force them to select cancel if they want to bail return canConnect(); } } return false; } } return true; }
From source file:org.gtdfree.GTDFree.java
/** * This method initializes jMenuItem //from w w w. ja v a2 s. c om * * @return javax.swing.JMenuItem */ private JMenuItem getAboutMenuItem() { if (aboutMenuItem == null) { aboutMenuItem = new JMenuItem(); aboutMenuItem.setText(Messages.getString("GTDFree.Help.About")); //$NON-NLS-1$ aboutMenuItem.setIcon(ApplicationHelper.getIcon(ApplicationHelper.icon_name_large_about)); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDialog aboutDialog = getAboutDialog(); //aboutDialog.pack(); Point loc = getJFrame().getLocation(); loc.translate(20, 20); aboutDialog.setLocation(loc); aboutDialog.setVisible(true); } }); } return aboutMenuItem; }
From source file:org.vpac.grisu.client.view.swing.mainPanel.Grisu.java
/** * This method initializes jMenuItem/*from w ww . j a va 2s. c o m*/ * * @return javax.swing.JMenuItem */ private JMenuItem getAboutMenuItem() { if (aboutMenuItem == null) { aboutMenuItem = new JMenuItem(); aboutMenuItem.setText("About"); aboutMenuItem.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { JDialog aboutDialog = getAboutDialog(); aboutDialog.pack(); Point loc = getJFrame().getLocation(); loc.translate(20, 20); aboutDialog.setLocation(loc); aboutDialog.setVisible(true); } }); } return aboutMenuItem; }