List of usage examples for javax.swing JOptionPane showOptionDialog
@SuppressWarnings("deprecation") public static int showOptionDialog(Component parentComponent, Object message, String title, int optionType, int messageType, Icon icon, Object[] options, Object initialValue) throws HeadlessException
initialValue
parameter and the number of choices is determined by the optionType
parameter. From source file:net.sf.taverna.t2.activities.localworker.actions.LocalworkerActivityConfigurationAction.java
/** * If the localworker has not been changed it pops up a {@link JOptionPane} warning the user * that they change things at their own risk. Otherwise just show the config view *///from w w w. jav a 2 s . c o m public void actionPerformed(ActionEvent e) { Object[] options = { "Continue", "Cancel" }; Configuration configuration = scufl2Tools.configurationFor(activity, activity.getParent()); JsonNode json = configuration.getJson(); if (!json.get("isAltered").booleanValue()) { int n = JOptionPane.showOptionDialog(null, "Changing the properties of a Local Worker may affect its behaviour. Do you want to continue?", "WARNING", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, // do not use a // custom Icon options, options[0]); if (n == 0) { // continue was clicked so prepare for config openDialog(); } else { // do nothing } } else { openDialog(); } }
From source file:edu.ku.brc.specify.config.init.RegisterSpecify.java
/** * @param title/*from ww w. j av a 2 s.c om*/ * @return */ private boolean askToReg(final String typeTitle, final String typeName) { Object[] options = { getResourceString("YES"), //$NON-NLS-1$ getResourceString("NO") //$NON-NLS-1$ }; int userChoice = JOptionPane.showOptionDialog(UIRegistry.getTopWindow(), getLocalizedMessage("SpReg.DO_REG", typeTitle, typeName), //$NON-NLS-1$ getResourceString("SpReg.DO_REG_TITLE"), //$NON-NLS-1$ JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); return userChoice == JOptionPane.YES_OPTION; }
From source file:com.aw.swing.mvp.ui.msg.MessageDisplayerImpl.java
public static boolean showConfirmMessage(Component parentContainer, String messageConfirm, int icon, int defaultButton) { ProcessMsgBlocker.instance().removeMessage(); int result = JOptionPane.showOptionDialog(parentContainer, messageConfirm, GENERIC_MESSAGE_TITLE, JOptionPane.YES_NO_OPTION, icon, null, options, options[defaultButton]); return (result == JOptionPane.YES_OPTION); }
From source file:gov.nih.nci.nbia.StandaloneDMV3.java
void checkCompatibility() { if (serverUrl.endsWith("DownloadServlet")) { this.serverUrl = serverUrl.concat("V3"); }//from www .j ava 2s. c o m if (!serverUrl.endsWith("DownloadServletV3")) { Object[] options = { "OK" }; int n = JOptionPane.showOptionDialog(frame, serverVersionMsg, "Incompatible Server Notification", JOptionPane.OK_OPTION, JOptionPane.INFORMATION_MESSAGE, null, options, options[0]); System.exit(n); } }
From source file:mobac.program.EnvironmentSetup.java
public static void checkFileSetup() { checkDirectory(DirectoryManager.userSettingsDir, "user settings", true); checkDirectory(DirectoryManager.atlasProfilesDir, "atlas profile", true); checkDirectory(DirectoryManager.tileStoreDir, "tile store", true); checkDirectory(DirectoryManager.tempDir, "temporary atlas download", true); if (!Settings.FILE.exists()) { try {/*w ww. j a v a2 s. c o m*/ FIRST_START = true; Settings.save(); } catch (Exception e) { log.error("Error while creating settings.xml: " + e.getMessage(), e); String[] options = { "Exit", "Show error report" }; int a = JOptionPane.showOptionDialog(null, "Could not create file settings.xml - program will exit.", "Error", 0, JOptionPane.ERROR_MESSAGE, null, options, options[0]); if (a == 1) GUIExceptionHandler.showExceptionDialog(e); System.exit(1); } } }
From source file:gate.Main.java
/** Run the user interface. */ protected static void runGui() throws GateException { Thread.currentThread().setPriority(Thread.MIN_PRIORITY); // initialise the library and load user CREOLE directories try {/*from w w w. j a v a 2 s. co m*/ Gate.init(); } catch (Throwable t) { log.error("Problem while initialising GATE", t); int selection = JOptionPane.showOptionDialog(null, "Error during initialisation:\n" + t.toString() + "\nDo you still want to start GATE?", "GATE", JOptionPane.YES_NO_OPTION, JOptionPane.ERROR_MESSAGE, null, new String[] { "Cancel", "Start anyway" }, "Cancel"); if (selection != 1) { System.exit(1); } } //create the main frame, show it SwingUtilities.invokeLater(new Runnable() { @Override public void run() { GraphicsConfiguration gc = GraphicsEnvironment.getLocalGraphicsEnvironment() .getDefaultScreenDevice().getDefaultConfiguration(); //this needs to run before any GUI component is constructed. applyUserPreferences(); //all the defaults tables have been updated; build the GUI frame = MainFrame.getInstance(gc); if (DEBUG) Out.prln("constructing GUI"); // run the GUI frame.setTitleChangable(true); frame.setTitle(name + " " + version + " build " + build); // Set title from Java properties String title = System.getProperty(GateConstants.TITLE_JAVA_PROPERTY_NAME); if (title != null) { frame.setTitle(title); } // if frame.setTitleChangable(false); // Set icon from Java properties // iconName could be absolute or "gate:/img/..." String iconName = System.getProperty(GateConstants.APP_ICON_JAVA_PROPERTY_NAME); if (iconName != null) { try { frame.setIconImage(Toolkit.getDefaultToolkit().getImage(new URL(iconName))); } catch (MalformedURLException mue) { log.warn("Could not load application icon.", mue); } } // if // Validate frames that have preset sizes frame.validate(); // Center the window Rectangle screenBounds = gc.getBounds(); Dimension screenSize = screenBounds.getSize(); Dimension frameSize = frame.getSize(); if (frameSize.height > screenSize.height) { frameSize.height = screenSize.height; } if (frameSize.width > screenSize.width) { frameSize.width = screenSize.width; } frame.setLocation((screenSize.width - frameSize.width) / 2, (screenSize.height - frameSize.height) / 2); frame.setVisible(true); //load session if required and available; //do everything from a new thread. Runnable runnable = new Runnable() { @Override public void run() { try { File sessionFile = Gate.getUserSessionFile(); if (sessionFile.exists()) { MainFrame.lockGUI("Loading saved session..."); PersistenceManager.loadObjectFromFile(sessionFile); } } catch (Exception e) { log.warn("Failed to load session data", e); } finally { MainFrame.unlockGUI(); } } }; Thread thread = new Thread(Thread.currentThread().getThreadGroup(), runnable, "Session loader"); thread.setPriority(Thread.MIN_PRIORITY); thread.start(); } }); registerCreoleUrls(); }
From source file:modelibra.swing.app.util.FileSelector.java
/** * Prompts a user to decide if the file should be replaced: yes or no. * //from w w w. j a va2 s . co m * @param parentFrame * parent window * @param lang * language * @return <code>true</code> if a user chooses yes */ protected boolean replaceFile(JFrame parentFrame, NatLang lang) { // Custom button text Object[] options = { lang.getText("yes"), lang.getText("no") }; JOptionPane.setDefaultLocale(lang.getLocale()); int response = JOptionPane.showOptionDialog(parentFrame, // parent // frame lang.getText("replaceFile"), // message lang.getText("fileExists"), // title JOptionPane.YES_NO_OPTION, // option type JOptionPane.QUESTION_MESSAGE, // message type null, // don't use a custom icon options, // the titles of buttons options[0]); // default button title if (response == JOptionPane.NO_OPTION) { return false; } return true; }
From source file:it.imtech.configuration.ChooseServer.java
/** * Connection serrver test, acquiring certificate if exists. * @param uri - Selected server URI//from w w w. j ava2 s . c o m * @return */ public static boolean testServerConnection(String uri) { Server s = (Server) choose_server.getSelectedItem(); boolean result = true; String outputFile = Globals.USER_DIR + "certs" + Utility.getSep() + "jssecacerts.jks"; //Aggiungo Keystore Temporaneo if (new File(outputFile).isFile()) { System.setProperty("javax.net.ssl.keyStore", outputFile); System.setProperty("javax.net.ssl.keyStorePassword", "changeit"); System.setProperty("javax.net.ssl.trustStore", outputFile); System.setProperty("javax.net.ssl.trustStorePassword", "changeit"); } try { URL url = new URL("https://" + uri); URLConnection con = url.openConnection(); Reader reader = new InputStreamReader(con.getInputStream()); } catch (SSLHandshakeException ex) { ResourceBundle bundle = ResourceBundle.getBundle(Globals.RESOURCES, Globals.CURRENT_LOCALE, Globals.loader); Object[] options = { Utility.getBundleString("voc1", bundle), Utility.getBundleString("voc2", bundle) }; int n = JOptionPane.showOptionDialog(null, Utility.getBundleString("phcertadd", bundle), Utility.getBundleString("phcertadd", bundle), JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); if (n == JOptionPane.YES_OPTION) { String[] run = new String[1]; run[0] = uri + ":443"; AddToStoreKey.createAndShowGUI(run); result = false; } } catch (Exception ex) { } return result; }
From source file:sim.util.media.chart.SeriesAttributes.java
void buildManipulators() { JButton removeButton = new JButton(I_CLOSE); removeButton.setPressedIcon(I_CLOSE_PRESSED); removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Remove", "Cancel" }, null) == 0) // remove getGenerator().removeSeries(getSeriesIndex()); }/*from w ww. j a v a 2 s . c o m*/ }); removeButton.setToolTipText("Remove this series"); JButton upButton = new JButton(I_UP); upButton.setPressedIcon(I_UP_PRESSED); upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); upButton.setBorderPainted(false); upButton.setContentAreaFilled(false); upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), true); } }); upButton.setToolTipText("Draw this series higher in the series order"); JButton downButton = new JButton(I_DOWN); downButton.setPressedIcon(I_DOWN_PRESSED); downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); downButton.setBorderPainted(false); downButton.setContentAreaFilled(false); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), false); } }); downButton.setToolTipText("Draw this series lower in the series order"); manipulators.add(removeButton); manipulators.add(upButton); manipulators.add(downButton); }
From source file:edu.gmu.cs.sim.util.media.chart.SeriesAttributes.java
void buildManipulators() { JButton removeButton = new JButton(I_CLOSE); removeButton.setPressedIcon(I_CLOSE_PRESSED); removeButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); removeButton.setBorderPainted(false); removeButton.setContentAreaFilled(false); removeButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (JOptionPane.showOptionDialog(null, "Remove the Series " + getSeriesName() + "?", "Confirm", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, new Object[] { "Remove", "Cancel" }, null) == 0) // remove {// w w w .j a va2s.c om getGenerator().removeSeries(getSeriesIndex()); } } }); removeButton.setToolTipText("Remove this series"); JButton upButton = new JButton(I_UP); upButton.setPressedIcon(I_UP_PRESSED); upButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); upButton.setBorderPainted(false); upButton.setContentAreaFilled(false); upButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), true); } }); upButton.setToolTipText("Draw this series higher in the series order"); JButton downButton = new JButton(I_DOWN); downButton.setPressedIcon(I_DOWN_PRESSED); downButton.setBorder(BorderFactory.createEmptyBorder(1, 1, 1, 1));//4,4,4,4)); downButton.setBorderPainted(false); downButton.setContentAreaFilled(false); downButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { getGenerator().moveSeries(getSeriesIndex(), false); } }); downButton.setToolTipText("Draw this series lower in the series order"); manipulators.add(removeButton); manipulators.add(upButton); manipulators.add(downButton); }