List of usage examples for javax.swing JOptionPane QUESTION_MESSAGE
int QUESTION_MESSAGE
To view the source code for javax.swing JOptionPane QUESTION_MESSAGE.
Click Source Link
From source file:Examples.java
public static void main(String args[]) { JFrame frame = new JFrame("Example Popup"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); Container contentPane = frame.getContentPane(); contentPane.setLayout(new GridLayout(0, 1)); JFrame frame2 = new JFrame("Desktop"); final JDesktopPane desktop = new JDesktopPane(); frame2.getContentPane().add(desktop); JButton pick = new JButton("Pick"); pick.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { System.out.println("Hi"); }/*from w w w .j a v a 2 s .c o m*/ }); frame2.getContentPane().add(pick, BorderLayout.SOUTH); JButton messagePopup = new JButton("Message"); contentPane.add(messagePopup); messagePopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showMessageDialog(source, "Printing complete"); JOptionPane.showInternalMessageDialog(desktop, "Printing complete"); } }); JButton confirmPopup = new JButton("Confirm"); contentPane.add(confirmPopup); confirmPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showConfirmDialog(source, "Continue printing?"); JOptionPane.showInternalConfirmDialog(desktop, "Continue printing?"); } }); JButton inputPopup = new JButton("Input"); contentPane.add(inputPopup); inputPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); JOptionPane.showInputDialog(source, "Enter printer name:"); // Moons of Neptune String smallList[] = { "Naiad", "Thalassa", "Despina", "Galatea", "Larissa", "Proteus", "Triton", "Nereid" }; JOptionPane.showInternalInputDialog(desktop, "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, smallList, "Triton"); // Moons of Saturn - includes two provisional designations to // make 20 String bigList[] = { "Pan", "Atlas", "Prometheus", "Pandora", "Epimetheus", "Janus", "Mimas", "Enceladus", "Tethys", "Telesto", "Calypso", "Dione", "Helene", "Rhea", "Titan", "Hyperion", "Iapetus", "Phoebe", "S/1995 S 2", "S/1981 S 18" }; // Object saturnMoon = JOptionPane.showInputDialog(source, "Pick // a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, // bigList, "Titan"); Object saturnMoon = JOptionPane.showInputDialog(source, "Pick a printer", "Input", JOptionPane.QUESTION_MESSAGE, null, bigList, null); System.out.println("Saturn Moon: " + saturnMoon); } }); JButton optionPopup = new JButton("Option"); contentPane.add(optionPopup); optionPopup.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent actionEvent) { Component source = (Component) actionEvent.getSource(); Icon greenIcon = new DiamondIcon(Color.green); Icon redIcon = new DiamondIcon(Color.red); Object iconArray[] = { greenIcon, redIcon }; JOptionPane.showOptionDialog(source, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, iconArray, iconArray[1]); Icon blueIcon = new DiamondIcon(Color.blue); Object stringArray[] = { "Do It", "No Way" }; JOptionPane.showInternalOptionDialog(desktop, "Continue printing?", "Select an Option", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, blueIcon, stringArray, stringArray[0]); } }); frame.setSize(300, 200); frame.setVisible(true); frame2.setSize(300, 200); frame2.setVisible(true); }
From source file:appmain.AppMain.java
public static void main(String[] args) { try {// w w w. ja v a2s . co m UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); UIManager.put("OptionPane.yesButtonText", "Igen"); UIManager.put("OptionPane.noButtonText", "Nem"); } catch (Exception ex) { ex.printStackTrace(); } try { AppMain app = new AppMain(); app.init(); File importFolder = new File(DEFAULT_IMPORT_FOLDER); if (!importFolder.isDirectory() || !importFolder.exists()) { JOptionPane.showMessageDialog(null, "Az IMPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } File exportFolder = new File(DEFAULT_EXPORT_FOLDER); if (!exportFolder.isDirectory() || !exportFolder.exists()) { JOptionPane.showMessageDialog(null, "Az EXPORT mappa nem elrhet!\n" + "Ellenrizze az elrsi utat s a jogosultsgokat!\n" + "Mappa: " + exportFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } List<File> xmlFiles = app.getXMLFiles(importFolder); if (xmlFiles == null || xmlFiles.isEmpty()) { JOptionPane.showMessageDialog(null, "Nincs beolvasand XML fjl!\n" + "Mappa: " + importFolder.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); return; } StringBuilder fileList = new StringBuilder(); xmlFiles.stream().forEach(xml -> fileList.append("\n").append(xml.getName())); int ret = JOptionPane.showConfirmDialog(null, "Beolvassra elksztett fjlok:\n" + fileList + "\n\nIndulhat a feldolgozs?", "Megtallt XML fjlok", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); if (ret == JOptionPane.OK_OPTION) { String csvName = "tranzakcio_lista_" + df.format(new Date()) + "_" + System.currentTimeMillis() + ".csv"; File csv = new File(DEFAULT_EXPORT_FOLDER + "/" + csvName); app.writeCSV(csv, Arrays.asList(app.getHeaderLine())); xmlFiles.stream().forEach(xml -> { List<String> lines = app.readXMLData(xml); if (lines != null) app.writeCSV(csv, lines); }); if (csv.isFile() && csv.exists()) { JOptionPane.showMessageDialog(null, "A CSV fjl sikeresen elllt!\n" + "Fjl: " + csv.getAbsolutePath(), "Informci", JOptionPane.INFORMATION_MESSAGE); app.openFile(csv); } } else { JOptionPane.showMessageDialog(null, "Feldolgozs megszaktva!", "Informci", JOptionPane.INFORMATION_MESSAGE); } } catch (Exception ex) { JOptionPane.showMessageDialog(null, "Nem kezelt kivtel!\n" + ExceptionUtils.getStackTrace(ex), "Hiba", JOptionPane.ERROR_MESSAGE); } }
From source file:kevin.gvmsgarch.App.java
public static void main(String[] args) throws HttpException, IOException, ParserConfigurationException, SAXException, XPathExpressionException, JSONException, InterruptedException { System.out.println("Google Voice Message Archiver"); System.out.println("Copyright (C) 2013 Kevin Carter"); System.out.println("This program comes with ABSOLUTELY NO WARRANTY"); System.out.println("This is free software, and you are welcome to redistribute it"); System.out.println("under certain conditions. See the LICENSE file or"); System.out.println("http://www.gnu.org/licenses/gpl-3.0.txt for details"); try {// w w w .j a v a 2s .c o m HttpClient c = new HttpClient(); String userName = getUserName(); String password = getPassword(); int locationChosenIndex = JOptionPane.CLOSED_OPTION; if (password != null) { locationChosenIndex = JOptionPane.showOptionDialog(null, "Message source", "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, Worker.ListLocation.values(), Worker.ListLocation.inbox); } if (locationChosenIndex != JOptionPane.CLOSED_OPTION) { int modeChosenIndex = 0; Worker.ArchiveMode modeChosen = null; Worker.ListLocation location = Worker.ListLocation.values()[locationChosenIndex]; Worker.ArchiveMode[] availableModes = location.getAllowedModes(); if (availableModes.length == 1) { modeChosen = availableModes[0]; } else { modeChosenIndex = JOptionPane.showOptionDialog(null, "Operation mode", "", JOptionPane.DEFAULT_OPTION, JOptionPane.QUESTION_MESSAGE, null, availableModes, Worker.ArchiveMode.archive); if (modeChosenIndex != JOptionPane.CLOSED_OPTION) { modeChosen = availableModes[modeChosenIndex]; } } ContactFilter filter = null; if (modeChosenIndex != JOptionPane.CLOSED_OPTION && locationChosenIndex != JOptionPane.CLOSED_OPTION) { filter = buildFilter(); } if (modeChosenIndex != JOptionPane.CLOSED_OPTION && locationChosenIndex != JOptionPane.CLOSED_OPTION && filter != null && areYouSure(modeChosen, location, filter)) { assert modeChosen != null : "ZOMG"; String authToken = getToken(userName, password); String rnrse = getRnrse(authToken); final ProgressMonitor pm = new ProgressMonitor(null, "Working", "", 0, App.parseMsgsLeft(extractInboxJson(authToken, location, 1))); pm.setMillisToDecideToPopup(0); pm.setMillisToPopup(0); Worker worker = new Worker(authToken, rnrse, pm, modeChosen, location, filter); worker.addPropertyChangeListener(new ProgressPropertyChangeListener(pm)); pm.setProgress(0); worker.execute(); } } } catch (Exception ex) { JOptionPane.showMessageDialog(null, ex.getMessage(), "ERROR", JOptionPane.ERROR_MESSAGE); } }
From source file:Main.java
public static int showOptionsDialog(String message, String... options) { return JOptionPane.showOptionDialog(null, message, "Select", JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[0]); }
From source file:Main.java
public static boolean confirmationPrompt(String msg, String title, Component parent) { Object[] options = { "Yes", "No" }; int n = JOptionPane.showOptionDialog(parent, msg, title, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); if (n == 0) { return true; } else {/*from w w w .j a va 2s. c o m*/ return false; } }
From source file:Main.java
/** * Shows a confirm dialog./*from ww w . j a v a2 s . co m*/ * * @param c * the parent component. * @param msg * the message to display. * @return an int indicating the option selected by the user. */ public static int showConfirmDialog(Component c, String msg) { return showConfirmDialog(c, msg, JOptionPane.QUESTION_MESSAGE); }
From source file:Main.java
/** * Displays a {@link JOptionPane} as an Input Dialog asking for a required text. * * @param title The title of the dialog. * @return The text written by the user. *//* w w w . j a va 2s.com*/ public static String askForRequiredTextUsingInputDialog(String title, String message) { String text = null; while (text == null || text.trim().equals("")) { text = JOptionPane.showInputDialog(null, message, title, JOptionPane.QUESTION_MESSAGE); } return text; }
From source file:Main.java
/** * Displays a yes/no question to the user. * //from w ww . j av a 2 s .c o m * @param parent the parent <code>Component</code> * @param message the message to display * @return <code>true</code> if the user pressed 'yes' */ public static boolean displayYesNoPrompt(Component parent, String message) { return (JOptionPane.YES_OPTION == JOptionPane.showOptionDialog(parent, message, null, JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null)); }
From source file:Main.java
/** * Displays a {@link JOptionPane} as a Confirm Dialog with OK and CANCEL buttons. * /*w ww. java 2s . co m*/ * @param title The title of the Dialog. * @param message The message of the Dialog. * @return "ok" or "cancel" if clicked on the respective buttons. */ public static String showConfirmationDialogWithOkCancelButtons(String title, String message) { int result = JOptionPane.showConfirmDialog(null, message, title, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (result == JOptionPane.OK_OPTION) return "ok"; if (result == JOptionPane.CANCEL_OPTION) return "cancel"; return null; }
From source file:Main.java
/** Show a confirmation message box with line wrapped message. * * 'optionType' is one of the JOptionPane.XXX_OPTION combination * constants, and the return value is one of the single-value * constants. *//* ww w .j a v a 2 s. c om*/ public static int confirmationBox(Component parent, String message, String title, int optionType) { JOptionPane pane = makeWordWrapJOptionPane(); pane.setMessage(message); pane.setMessageType(JOptionPane.QUESTION_MESSAGE); pane.setOptionType(optionType); JDialog dialog = pane.createDialog(parent, title); dialog.setVisible(true); Object result = pane.getValue(); if (result == null || !(result instanceof Integer)) { return JOptionPane.CLOSED_OPTION; } else { return ((Integer) result).intValue(); } }