List of utility methods to do JOptionPane Message
void | showExceptionMessage(Component parent, Throwable t) Shows a message box with exception details. StringBuilder sb = new StringBuilder(); sb.append("An unexpected error occured during the execution of the requested task.\n"); sb.append("The error data can be seen below:\n\n"); sb.append(t.getLocalizedMessage()); sb.append(t.toString()).append("\n"); sb.append("Stack Trace:\n"); for (StackTraceElement e : t.getStackTrace()) { sb.append(e.toString()).append("\n"); ... |
void | showExceptionMessage(Component parentComponent, Exception exception) Show an Exception dialogue. StringWriter stringWriter = new StringWriter(); exception.printStackTrace(new PrintWriter(stringWriter)); JLabel message = new JLabel(exception.getMessage()); message.setBorder(BorderFactory.createEmptyBorder(3, 0, 10, 0)); JTextArea text = new JTextArea(); text.setEditable(false); text.setFont(UIManager.getFont("Label.font")); text.setText(stringWriter.toString()); ... |
boolean | showExceptionMessage(Exception e) show Exception Message try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); } catch (Exception el) { JOptionPane.showMessageDialog(new JDialog(), e.getMessage()); el.printStackTrace(); JOptionPane.showMessageDialog(new JDialog(), e.getMessage()); e.printStackTrace(); ... |
void | showExceptionMessage(Exception e) show Exception Message String msg = "An exception has occurred.\n\n" + e.toString() + "\n\nIf problems persist, please contact your local administrator."; e.printStackTrace(System.out); JOptionPane.showMessageDialog(mainComponent, msg, "Exception", JOptionPane.ERROR_MESSAGE); |
String | showInput(Component parent, String message, String initValue) Show a input dialog. String input = null;
input = JOptionPane.showInputDialog(parent, message, initValue);
return input;
|
Optional | showInput(String message) show Input return Optional.ofNullable(JOptionPane.showInputDialog(message));
|
Optional | showInputInteger(String message) show Input Integer Optional<String> input = showInput(message); if (input.isPresent()) { try { return Optional.of(Integer.valueOf(input.get())); } catch (NumberFormatException e) { return Optional.empty(); } else { ... |
void | showInvalidJarPathMessage(String jarPath) show Invalid Jar Path Message String message = "Unable to restart cmanager. Settings could not be applied.\n" + "Expected path: " + jarPath; JOptionPane.showMessageDialog(null, message, "jar path", JOptionPane.ERROR_MESSAGE); |
void | showLog(int type, String title, String message) show Log JOptionPane.showMessageDialog(null, message, title, type); |
void | showMessage(Component c, String message, String title) Utility method to display a popup with the provided message and title JOptionPane.showMessageDialog(c, message, title, JOptionPane.INFORMATION_MESSAGE); |