JOptionPane.showMessageDialog
 Show a message and wait for the user to click OK.
 
showConfirmDialog
 Show a message and get a confirmation (like OK/Cancel).
 
showOptionDialog
 Show a message and get a user option from a set of options.
 
showInputDialog
 Show a message and get one line of user input.
 

解决方案 »

  1.   

    javax.swing.JOptionPane 
    方法:
    showConfirmDialog  Asks a confirming question, like yes/no/cancel.  
    showInputDialog    Prompt for some input.  
    showMessageDialog  Tell the user about something that has happened.  
    showOptionDialog   The Grand Unification of the above three. 
      

  2.   


    这里只是小部分,希望楼主看看看JB的help.毕竟那里的这些方法好多,而且参数不一样!1.showMessageDialog public static void showMessageDialog(Component parentComponent,
                                         Object message,
                                         String title,
                                         int messageType)    Brings up a dialog that displays a message using a default icon determined by the messageType parameter.Parameters:parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is usedmessage - the Object to displaytitle - the title string for the dialogmessageType - the type of message to be displayed: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE2.showOptionDialog public static int showOptionDialog(Component parentComponent,
                                       Object message,
                                       String title,
                                       int optionType,
                                       int messageType,
                                       Icon icon,
                                       Object[] options,
                                       Object initialValue) 
      Brings up a modal dialog with a specified icon, where the initial choice is dermined by the initialValue parameter and the number of choices is determined by the optionType parameter. If optionType is YES_NO_OPTION, or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the Look and Feel. The messageType parameter is primarily used to supply a default icon from the Look and Feel.Parameters:parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is usedmessage - the Object to displaytitle - the title string for the dialogoptionType - an integer designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTIONmessageType - an integer designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGEicon - the icon to display in the dialogoptions - an array of objects indicating the possible choices the user can make; if the objects are components, they are rendered properly; non-String objects are rendered using their toString methods; if this parameter is null, the options are determined by the Look and Feel.initialValue - the object that represents the default selection for the dialogReturns:an integer indicating the option chosen by the user, or CLOSED_OPTION if the user closed the Dialog3.showConfirmDialog public static int showConfirmDialog(Component parentComponent,
                                        Object message,
                                        String title,
                                        int optionType,
                                        int messageType,
                                        Icon icon) 
      Brings up a modal dialog with a specified icon, where the number of choices is determined by the optionType parameter. The messageType parameter is primarily used to supply a default icon from the Look and Feel.Parameters:parentComponent - determines the Frame in which the dialog is displayed; if null, or if the parentComponent has no Frame, a default Frame is usedmessage - The Object to displaytitle - the title string for the dialogoptionType - an int designating the options available on the dialog: YES_NO_OPTION, or YES_NO_CANCEL_OPTIONmessageType - an int designating the kind of message this is, primarily used to determine the icon from the pluggable Look and Feel: ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGEicon - the icon to display in the dialogReturns:an int indicating the option selected by the user
      

  3.   

    JOptionPane() 
    ——Creates a JOptionPane with a test message. JOptionPane(Object message) 
    ——Creates a instance of JOptionPane to display a message using the plain-message message type and the default options delivered by the UI. JOptionPane(Object message, int messageType) 
    ——Creates an instance of JOptionPane to display a message with the specified message type and the default options, JOptionPane(Object message, int messageType, int optionType) 
    ——Creates an instance of JOptionPane to display a message with the specified message type and options. JOptionPane(Object message, int messageType, int optionType, Icon icon) 
    ——Creates an instance of JOptionPane to display a message with the specified message type, options, and icon. JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options) 
    ——Creates an instance of JOptionPane to display a message with the specified message type, icon, and options. JOptionPane(Object message, int messageType, int optionType, Icon icon, Object[] options, Object initialValue) 
    ——Creates an instance of JOptionPane to display a message with the specified message type, icon, and options, with the initially-selected option specified. 
      

  4.   

    JOptionPane.showMessageDialog(Component parentComponent, Object message) JOptionPane.showMessageDialog(Component parentComponent, Object message, String title, int messageType) JOptionPane.showMessageDialog(Component parentComponent, Object message, String title, int messageType, Icon icon)