JOptionPane makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something.
There's some shortcut to do there with static methods like showMessageDialog
,
showInputDialog
. But if you want to make a hole control of JOptionPane,
you can create a JOptionPane by yourself and append it into a your JFrame.
new JOptionPane()
static public OK_STR:String
static public CANCEL_STR:String
static public YES_STR:String
static public NO_STR:String
static public CLOSE_STR:String
static public OK:Number
static public CANCEL:Number
static public YES:Number
static public NO:Number
static public CLOSE:Number
static public function showMessageDialog(title:String, msg:String, finishHandler:Function, parentComponent:Component, modal:Boolean, icon:Icon, buttons:Number):JOptionPane
showMessageDialog(title:String, msg:String, finishHandler:Function, parentComponent:Component, modal:Boolean, icon:Icon, buttons:Number)
showMessageDialog(title:String, msg:String, finishHandler:Function, parentComponent:Component, modal:Boolean, icon:Icon)
showMessageDialog(title:String, msg:String, finishHandler:Function, parentComponent:Component, modal:Boolean)
showMessageDialog(title:String, msg:String, finishHandler:Function, parentComponent:Component)
showMessageDialog(title:String, msg:String, finishHandler:Function)
Show a message box with specifield title, message, and icon.
for example:
var handler:Function = Delegate.create(this, __whenUserConformed); var pane:JOptionPane = showMessageDialog("title", "is that OK?", handler, null, JOptionPane.YES|JOptionPane.NO);will show a message box with yes and no buttons.
title | the title of the box, can be null |
msg | the message , can be null |
finishHandler | the function(result:Number) to call when user finished input, will pass a number as parammeter, its value indicate what user's selection. For example CANCEL indicate that user pressed CANCEL button, CLOSE indicate that user pressed CLOSE button or just closed the frame by click frame's close button, YES indicate that user pressed the YES button etc. |
parentComponent | determines the Frame in which the dialog is displayed; can be null |
modal | is the window modal, default is true |
icon | the icon, can be null |
buttons | which buttons need to show. |
static public function showInputDialog(title:String, msg:String, finishHandler:Function, defaultValue:String, parentComponent:Component, modal:Boolean, icon:Icon):JOptionPane
showMessageDialog(title:String, msg:String, finishHandler:Function, defaultValue:String, parentComponent:Component, modal:Boolean, icon:Icon)
showMessageDialog(title:String, msg:String, finishHandler:Function, defaultValue:String, parentComponent:Component, modal:Boolean)
showMessageDialog(title:String, msg:String, finishHandler:Function, defaultValue:String, parentComponent:Component)
showMessageDialog(title:String, msg:String, finishHandler:Function, defaultValue:String)
showMessageDialog(title:String, msg:String, finishHandler:Function)
Show a message box with specifield title, message, and icon and a TextField to requare user to input a string.
for example:
var handler:Function = Delegate.create(this, __whenUserEntered); var pane:JOptionPane = showMessageDialog("title", "Please enter your name:", handler, "yournamehere");will show a message box with OK and CANCEL and a input Texts.
title | the title of the box, can be null |
msg | the message , can be null |
finishHandler | the function(result:String) to call when user finished input, will pass a string as parammeter, if it is null indicate that user had pressed cancel or just closed the frame, otherwise it is the string what user entered. |
defaultValue | the default value for the input |
parentComponent | determines the Frame in which the dialog is displayed; can be null |
modal | is the window modal, default is true |
icon | the icon, can be null |