[转]java 常用弹出框

显示一个错误对话框,该对话框显示的 message 为 'alert':

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


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

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


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

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


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

  1. JOptionPane.showInternalConfirmDialog(frame,    
  2.     "please choose one""information",    
  3.     JOptionPane.YES_NO_CANCEL_OPTION, 
  4.     JOptionPane.INFORMATION_MESSAGE);        


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

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


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

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

 

 

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

  1. Object[] possibleValues = { "First""Second""Third" };   
  2. Object selectedValue = JOptionPane.showInputDialog(null,  "Choose one""Input",    
  3.     JOptionPane.INFORMATION_MESSAGE, null
  4.     possibleValues, possibleValues[0]);   
posted @ 2013-12-25 20:09  1angxi  阅读(418)  评论(0编辑  收藏  举报