Java 饮弹出对话框的几种方式

Java 中弹出对话框的几种方式
显示一个错误对话框,该对话框显示的 message 为 'alert':

JOptionPane.showMessageDialog(null, "alert", "alert", JOptionPane.ERROR_MESSAGE);    

显示一个内部信息对话框,其 message 为 'information': 

JOptionPane.showInternalMessageDialog(frame, "information","information", JOptionPane.INFORMATION_MESSAGE);    

显示一个信息面板,其 options 为 "yes/no",message 为 'choose one': 

JOptionPane.showConfirmDialog(null, "choose one", "choose one", JOptionPane.YES_NO_OPTION);    

显示一个内部信息对话框,其 options 为 "yes/no/cancel",message 为 'please choose one',并具有 title 信息: 

JOptionPane.showInternalConfirmDialog(frame,     
    "please choose one", "information",     
    JOptionPane.YES_NO_CANCEL_OPTION,  
    JOptionPane.INFORMATION_MESSAGE);         

显示一个警告对话框,其 options 为 OK、CANCEL,title 为 'Warning',message 为 'Click OK to continue': 

Object[] options = { "OK", "CANCEL" };    
JOptionPane.showOptionDialog(null, "Click OK to continue", "Warning",     
    JOptionPane.DEFAULT_OPTION, JOptionPane.WARNING_MESSAGE,     
    null, options, options[0]);    

显示一个要求用户键入 String 的对话框: 

String inputValue = JOptionPane.showInputDialog("Please input a value");    
 

 

显示一个要求用户选择 String 的对话框:

Object[] possibleValues = { "First", "Second", "Third" };    
Object selectedValue = JOptionPane.showInputDialog(null,  "Choose one", "Input",     
    JOptionPane.INFORMATION_MESSAGE, null,  
    possibleValues, possibleValues[0]);