Java Utililty Methods JOptionPane Message

List of utility methods to do JOptionPane Message

Description

The list of methods to do JOptionPane Message are organized into topic(s).

Method

intdisplay2(Component parent, String message, String title, int optionType, int messageType, Icon icon)
display
return JOptionPane.showConfirmDialog(parent, message, title, optionType, messageType, icon);
StringdisplayEditor(Component parent, String title, String msg)
display Editor
JTextArea editArea = new JTextArea(msg, 5, 30);
editArea.setEditable(true);
editArea.setLineWrap(true);
JScrollPane scroll = new JScrollPane(editArea, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
        JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
final JOptionPane optionPane = new JOptionPane(scroll, JOptionPane.PLAIN_MESSAGE,
        JOptionPane.OK_CANCEL_OPTION);
JDialog dialog = optionPane.createDialog(parent, title);
...
StringdisplayInputMessage(String title, String message, String defaultInput)
display Input Message
String result = JOptionPane.showInputDialog(getFrontWindow(), message, title, JOptionPane.QUESTION_MESSAGE);
if (result != null && result.length() > 0) {
    return result;
return null;
StringdisplayInputMessage(String title, String message, String defaultInput)
Display a dialog that gets an input string from the user.
String result = JOptionPane.showInputDialog(getMainWindow(), message, "Savant",
        JOptionPane.QUESTION_MESSAGE);
if (result != null && result.length() > 0) {
    return result;
return null;
voiddisplayMessage(Component parent, String string, String title)
display Message
JOptionPane.showMessageDialog(parent, string, title, JOptionPane.INFORMATION_MESSAGE);
voiddisplayMessage(Component parentComponent, String message, String windowTitle, int messageType)
display Message
JOptionPane p = new JOptionPane(message, messageType) {
    public int getMaxCharactersPerLineCount() {
        return 72;
};
p.setMessage(message);
JDialog dialog = p.createDialog(parentComponent, windowTitle);
dialog.setVisible(true);
...
voiddisplayMessage(String message)
Display a Savant message dialog with the given message and the title "MedSavant".
displayMessage("MedSavant", message);
voiddisplayMessagePane(String desc, String title)
This function displays the JOptionPane with title and descritpion
if (title == null)
    title = "Message Dialog";
JOptionPane.showMessageDialog(null, desc, title, JOptionPane.PLAIN_MESSAGE);
voidexcMsg(String msg, Exception ex)
Exception message dialog.
final String fullMsg = msg += LS + "Exception: " + ex + LS + ex.getMessage();
SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        JOptionPane.showMessageDialog(null, fullMsg, "Error", JOptionPane.ERROR_MESSAGE);
        System.out.println(fullMsg);
});
voidexcMsg(String msg, Exception ex)
Exception message dialog.
final String fullMsg = msg += LS + "Exception: " + ex + LS + ex.getMessage();
SwingUtilities.invokeLater(new Runnable() {
    public void run() {
        JOptionPane.showMessageDialog(null, fullMsg, "Error", JOptionPane.ERROR_MESSAGE);
        System.out.println(fullMsg);
});