List of usage examples for javax.swing JOptionPane createDialog
public JDialog createDialog(String title) throws HeadlessException
JDialog
with the specified title. From source file:Main.java
public static void main(String[] args) throws Exception { JOptionPane jop = new JOptionPane("Message", JOptionPane.QUESTION_MESSAGE, JOptionPane.DEFAULT_OPTION); JDialog dialog = jop.createDialog("Dialog Title"); Image image = ImageIO.read(new URL("http://www.java2s.com/style/download.png")); dialog.setIconImage(image);/*from www . j a va 2 s .c o m*/ dialog.setVisible(true); }
From source file:Main.java
public static void main(String[] args) { JOptionPane pane = new JOptionPane("JOptionPane", JOptionPane.INFORMATION_MESSAGE); String dialogTitle = "Resizable Custom Dialog"; JDialog dialog = pane.createDialog(dialogTitle); dialog.setResizable(true);// ww w. ja v a2 s . c o m dialog.setVisible(true); }
From source file:com.quinsoft.zeidon.utils.JoeUtils.java
public static final void sysMessageBox(String msgTitle, String msgText) { //JOptionPane.showMessageDialog( null, msgText, msgTitle, JOptionPane.PLAIN_MESSAGE ); JOptionPane pane = new JOptionPane(msgText, JOptionPane.INFORMATION_MESSAGE); JDialog dialog = pane.createDialog(msgTitle); dialog.setModalityType(ModalityType.MODELESS); dialog.setAlwaysOnTop(true);/*from w w w. j a va2s .c o m*/ dialog.setVisible(true); }
From source file:edu.umass.cs.gnsserver.installer.EC2Runner.java
private static boolean showDialog(String message, final long timeout) { try {/* www .j a v a 2 s . c o m*/ int dialog = JOptionPane.YES_NO_OPTION; JOptionPane optionPane = new JOptionPane(message, JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION); final JDialog dlg = optionPane.createDialog("Error"); new Thread(new Runnable() { @Override public void run() { { ThreadUtils.sleep(timeout); dlg.dispose(); } } }).start(); dlg.setVisible(true); int value = ((Integer) optionPane.getValue()).intValue(); if (value == JOptionPane.YES_OPTION) { return true; } else { return false; } } catch (RuntimeException e) { return true; } }
From source file:Main.java
private void displayGUI() { JOptionPane optionPane = new JOptionPane(getPanel(), JOptionPane.PLAIN_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}, null); dialog = optionPane.createDialog("import"); dialog.setVisible(true);/* w w w . jav a 2 s .com*/ }
From source file:com.gs.obevo.util.inputreader.DialogInputReader.java
@Override public String readPassword(String promptMessage) { final JPasswordField jpf = new JPasswordField(); JOptionPane jop = new JOptionPane(jpf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = jop.createDialog(promptMessage); dialog.addComponentListener(new ComponentAdapter() { @Override//w w w . j a v a 2 s .c om public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { jpf.requestFocusInWindow(); } }); } }); dialog.setVisible(true); int result = (Integer) jop.getValue(); dialog.dispose(); String password = null; if (result == JOptionPane.OK_OPTION) { password = new String(jpf.getPassword()); } if (StringUtils.isEmpty(password)) { return null; } else { return password; } }
From source file:com.gs.obevo.util.inputreader.DialogInputReader.java
@Override public String readLine(String promptMessage) { final JTextField juf = new JTextField(); JOptionPane juop = new JOptionPane(juf, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog userDialog = juop.createDialog(promptMessage); userDialog.addComponentListener(new ComponentAdapter() { @Override/*from w w w . j a va 2 s.c o m*/ public void componentShown(ComponentEvent e) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { juf.requestFocusInWindow(); } }); } }); userDialog.setVisible(true); int uresult = (Integer) juop.getValue(); userDialog.dispose(); String userName = null; if (uresult == JOptionPane.OK_OPTION) { userName = new String(juf.getText()); } if (StringUtils.isEmpty(userName)) { return null; } else { return userName; } }
From source file:cz.nn.copytables.gui.CopyTablesGUI.java
void showErrorPane(String title, String msg) { logger.error(msg);/*from w ww . j a v a2s .c o m*/ JOptionPane pane = new JOptionPane(msg, JOptionPane.ERROR_MESSAGE); JDialog dialog = pane.createDialog("Application says: " + title); dialog.setAlwaysOnTop(true); dialog.setVisible(true); }
From source file:eu.asterics.mw.services.AstericsErrorHandling.java
/** * This method is used by the components to report an error. It logs the error in "warning" logger * and sets the status of the ARE to "ERROR" to denote that an error has occurred * @param component the component instance that reports the error * @param errorMsg the error message//from w w w . ja v a 2s . c om */ public void reportError(IRuntimeComponentInstance component, final String errorMsg) { if (component != null) { String componentID = DeploymentManager.instance .getIRuntimeComponentInstanceIDFromIRuntimeComponentInstance(component); if (componentID != null) { //System.out.println("componentID: "+componentID); logger.warning(componentID + ": " + errorMsg); setStatusObject(AREStatus.ERROR.toString(), componentID, errorMsg); } } AREProperties props = AREProperties.instance; if (props.checkProperty("showErrorDialogs", "1")) { SwingUtilities.invokeLater(new Runnable() { @Override public void run() { ErrorLogPane.appendLog(errorMsg); DeploymentManager.instance.setStatus(AREStatus.ERROR); AstericsErrorHandling.this.notifyAREEventListeners("onAreError", errorMsg); JOptionPane op = new JOptionPane(errorMsg, JOptionPane.WARNING_MESSAGE); JDialog dialog = op.createDialog("AsTeRICS Runtime Environment:"); dialog.setAlwaysOnTop(true); dialog.setModal(false); dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); dialog.setVisible(true); } }); } }
From source file:com.raceup.fsae.test.TesterGui.java
/** * Shows dialog with info about unsuccessful test submission *//*from ww w .j a va2s . co m*/ private void showUnSuccessfulTestSubmissionDialog() { totalTestTimer.start(); // re-start total timer String message = test.toString(); message += "\nDon't worry, be happy: this box will automatically " + "close after " + Integer.toString(SECONDS_WAIT_BETWEEN_SUBMISSIONS) + " seconds of your " + "submission.\nEnjoy."; JOptionPane opt = new JOptionPane(message, JOptionPane.WARNING_MESSAGE, JOptionPane.DEFAULT_OPTION, null, new Object[] {}); // no buttons final JDialog dlg = opt.createDialog("Error"); new Thread(() -> { try { Thread.sleep(SECONDS_WAIT_BETWEEN_SUBMISSIONS * 1000); dlg.dispose(); } catch (Throwable t) { System.err.println(t.toString()); } }).start(); dlg.setVisible(true); }