List of usage examples for javax.swing JDialog setLocationByPlatform
public void setLocationByPlatform(boolean locationByPlatform)
From source file:org.drugis.addis.gui.WelcomeDialog.java
private void showExampleInfo(String helpText) { final JDialog dialog = new JDialog(this); dialog.setLocationByPlatform(true); dialog.setPreferredSize(new Dimension(500, 250)); JComponent helpPane = TextComponentFactory.createTextPane(helpText, true); JButton closeButton = new JButton("Close"); closeButton.setMnemonic('c'); closeButton.addActionListener(new AbstractAction() { public void actionPerformed(ActionEvent arg0) { dialog.dispose();//from w w w . j a v a2 s . c o m } }); JPanel panel = new JPanel(new BorderLayout()); panel.add(helpPane, BorderLayout.CENTER); panel.add(closeButton, BorderLayout.SOUTH); dialog.add(panel); dialog.pack(); dialog.setVisible(true); }
From source file:org.languagetool.gui.Tools.java
/** * Set dialog location to the center of the screen * * @param dialog the dialog which will be centered * @since 2.6//from w w w . j ava2s . c o m */ public static void centerDialog(JDialog dialog) { Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); Dimension frameSize = dialog.getSize(); dialog.setLocation(screenSize.width / 2 - frameSize.width / 2, screenSize.height / 2 - frameSize.height / 2); dialog.setLocationByPlatform(true); }