List of utility methods to do JOptionPane Message
boolean | queryBoolean(String message) Queries the User for a Boolean value. int revan = JOptionPane.showConfirmDialog(null, message); return (revan == JOptionPane.YES_OPTION); |
double | queryDouble(String message, double initialValue) Queries the User for a Double values using Swing. String input = JOptionPane.showInputDialog(message, "" + initialValue); if (input == null) throw new Exception("Selection aborted"); return Double.parseDouble(input); |
int | queryInt(String message, int initialValue) Queries the User for an Integer value using Swing. String input = JOptionPane.showInputDialog(message, "" + initialValue); if (input == null) throw new Exception("Selection aborted"); return Integer.parseInt(input); |
String | requestPassword(String titulo, String msg) request Password JPanel panel = new JPanel(); JLabel label = new JLabel(msg); JPasswordField pass = new JPasswordField(10); panel.add(label); panel.add(pass); pass.requestFocusInWindow(); String[] options = new String[] { "OK", "Cancelar" }; int option = JOptionPane.showOptionDialog(null, panel, titulo, JOptionPane.NO_OPTION, ... |
int | select(String[] selList, String msg) select JComboBox<String> box = new JComboBox<>(selList); Object msgs[] = new Object[2]; msgs[0] = msg; msgs[1] = box; int result = JOptionPane.showOptionDialog(null, msgs, msg, JOptionPane.OK_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE, null, null, null); if (result == JOptionPane.CANCEL_OPTION) return -1; ... |
Object | show(String title, int type, Object message, Object[] options, Object initialOption) Helper method for constructing an always-on-top modal dialog. if (options == null) { options = new Object[] { "Ok" }; initialOption = "Ok"; JOptionPane p = new JOptionPane(message, type, JOptionPane.DEFAULT_OPTION, null, options, initialOption); p.setInitialValue(initialOption); JDialog d = p.createDialog(null, title); p.selectInitialValue(); ... |
void | showActionFailedWithExceptionMessage(final Component parent, final Exception ex) show Action Failed With Exception Message SwingUtilities.invokeLater(new Runnable() { @Override public void run() { JOptionPane.showMessageDialog(parent, "Die Aktion konnten nicht abgeschlossen werden, da folgender Fehler auftrat:\n<HTML><I>" + ex.getLocalizedMessage() + "</I></HTML>", "Aktion fehlgeschlagen", JOptionPane.ERROR_MESSAGE); }); |
void | showAlert(String message) Uses the JOptionPane.showMessageDialog() method to display the specified alert message. JOptionPane.showMessageDialog(null, message, "JFMI Alert", JOptionPane.INFORMATION_MESSAGE);
|
void | showException(Component c, String message, Throwable t) Utility method to display a popup with the provided message ant Throwable if (t == null) { t = new Exception("Unknown Exception"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); t.printStackTrace(new PrintStream(baos)); if (message == null) { message = t.getClass().getName(); String stackTrace = baos.toString(); message += System.getProperty("line.separator") + stackTrace; JOptionPane.showMessageDialog(c, message, "Error Message", JOptionPane.ERROR_MESSAGE); |
void | showException(String message, Exception ex) Presents a modal dialog displaying the given message and information about the given exception. ex.printStackTrace(); JOptionPane.showMessageDialog(null, message + "\n\n" + ex + "\n"); |