List of utility methods to do JOptionPane Message
void | excMsg(String msg, Throwable t) Exception message dialog. msg += "\n" + "Throwable: " + t + "\n" + t.getMessage(); JOptionPane.showMessageDialog(null, msg, "Error", JOptionPane.ERROR_MESSAGE); System.out.println(msg); |
void | exibeMsg(String msg, int tipoMsg) exibe Msg JOptionPane.showMessageDialog(framePrincipal, msg, tituloJanelaMsg, tipoMsg); |
Icon | getIconForType(int messageType) get Icon For Type if (messageType < 0 || messageType > 3) { return null; switch (messageType) { case JOptionPane.ERROR_MESSAGE: return UIManager.getIcon("OptionPane.errorIcon"); case JOptionPane.INFORMATION_MESSAGE: return UIManager.getIcon("OptionPane.informationIcon"); ... |
String | getInput(String msg, String defaultInput) get Input String input = (String) JOptionPane.showInputDialog(msg, defaultInput);
return input;
|
int | getInt(String message, int min, int max, Integer initialValue) get Int Integer i = null; while (i == null) { String s = JOptionPane.showInputDialog(message + " (" + min + " to " + max + ")", initialValue); try { i = Integer.parseInt(s); } catch (Exception e) { return i; |
int | getIntegerFromImput(String message, int min, int max) get Integer From Imput int num = 0; JOptionPane optPane = new JOptionPane(message + " - Insert integer value: [" + min + "," + max + "]", JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); optPane.setWantsInput(true); boolean isOk = false; while (!isOk) { try { JDialog d = optPane.createDialog(null, "Input Value"); ... |
int | getIntegerInput(String message) get Integer Input int input = 0; while (true) { boolean check = true; try { input = Integer.parseInt(JOptionPane.showInputDialog(null, message, "")); } catch (NumberFormatException e) { check = false; if (check == true) break; return input; |
Icon | getJOptionPaneIcon(int jOptionPaneMessageType) Get the icon used in the JOptionPane to signify its message type. Integer messageTypeInteger = new Integer(jOptionPaneMessageType); Icon icon = jOptionPaneMessageTypeToIconMap.get(messageTypeInteger); if (icon == null) { OptionPaneUI ui = (new JOptionPane()).getUI(); if (!(ui instanceof BasicOptionPaneUI)) { ui = new BasicOptionPaneUI(); JOptionPane optionPane = new JOptionPane(); optionPane.setUI(ui); ... |
String | getPassword(String message) get Password JPasswordField passwordField = new JPasswordField(); JOptionPane.showConfirmDialog(null, passwordField, message, JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE); return new String(passwordField.getPassword()); |
String | getString(Component component, String message) get String String value = JOptionPane.showInputDialog(component, message);
return value;
|