List of utility methods to do JOptionPane Message
void | alert(Component component, String title, String msg) alert JOptionPane.showMessageDialog(component, msg, title, JOptionPane.ERROR_MESSAGE); |
String | askPassword(String message) ask Password JLabel wLabel = new JLabel(message); final JPasswordField wPwd = new JPasswordField(); JOptionPane jop = new JOptionPane(new Object[] { wLabel, wPwd }, JOptionPane.QUESTION_MESSAGE, JOptionPane.OK_CANCEL_OPTION); JDialog dialog = jop.createDialog(null, "Password"); dialog.addComponentListener(new ComponentAdapter() { @Override public void componentShown(ComponentEvent e) { ... |
void | browse(String url, Component msgParent) Opens the given website in the default browser, or shows a message saying that no default browser could be accessed. boolean error = false; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) { try { Desktop.getDesktop().browse(new URI(url)); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } catch (IOException ex) { error = true; ... |
void | browse(String url, Component msgParent) Opens the given website in the default browser, or shows a message saying that no default browser could be accessed. boolean error = false; if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Action.BROWSE)) { try { Desktop.getDesktop().browse(new URI(url)); } catch (URISyntaxException ex) { throw new RuntimeException(ex); } catch (IOException ex) { error = true; ... |
int | chooseIndex(String message, String messageTitle, Object[] objects, Object initialObject) Asks the User to select an Object from a given array of Objects. Object input = JOptionPane.showInputDialog(null, message, messageTitle, JOptionPane.INFORMATION_MESSAGE, null, objects, initialObject); if (input == null) throw new Exception("Selection aborted"); int index = -1; for (int i = 0; i < objects.length; i++) { if (objects[i].equals(input)) index = i; ... |
Object | chooseObject(String message, String messageTitle, Object[] objects, Object initialObject) Asks the User to select an Object from a given array of Objects. Object input = JOptionPane.showInputDialog(null, message, messageTitle, JOptionPane.INFORMATION_MESSAGE, null, objects, initialObject); if (input == null) throw new Exception("Selection aborted"); return input; |
void | copyToClipBoard(String code, boolean displayMessage) copy To Clip Board java.awt.datatransfer.StringSelection selection = new java.awt.datatransfer.StringSelection(code); java.awt.Frame frame = new java.awt.Frame(); frame.getToolkit().getSystemClipboard().setContents(selection, selection); if (displayMessage) { JOptionPane.showMessageDialog(null, "Code copied to Clipboard", "Finished", JOptionPane.INFORMATION_MESSAGE); frame.dispose(); ... |
void | createPane(Component comp, String msg) create Pane JOptionPane pane = new JOptionPane(msg); final JDialog dialog = pane.createDialog(comp, "INFORMATION"); Timer timer = new Timer(4000, new ActionListener() { public void actionPerformed(ActionEvent evt) { dialog.dispose(); }); timer.setRepeats(false); ... |
JOptionPane | createPane(int type, String message, int messageMaxLength) create Pane JOptionPane pane = createMaxLengthOptionPane(messageMaxLength);
pane.setMessageType(type);
pane.setMessage(message);
return pane;
|
void | debug(String message) Utility method that can be used to display a debug message. JOptionPane.showMessageDialog(null, message); |