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.
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.
解决方案 »
- visitor模式和bridge模式,到底区别在哪里?
- 如何简便清除drawLine绘制的直线?
- 新手问一个简单的问题,在线等,只希望有谁能来帮帮我(急)
- Jtree多选问题,如何获得选择的那些节点的路径??????
- 超级简单问题,紧急求助,有关package打得包,程序访问不到的问题!!!!!!!!!!!
- ** 如何为JPanel添加类似BCB中的事件触发机制???
- 寻合租的室友!!
- 请问jbuilder中有没有类似于Vb中的ListView的组件
- 着急,在线等待答案,哪里有不需要注册的Jcreator ?
- 请问:怎样把一个文本文件的所有内容都读进一个String 里面呢??
- 请问怎么用文件名过滤FilenameFilter这个接口啊?
- 一个简单的对象申明和定义的问题
方法:
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.
这里只是小部分,希望楼主看看看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
——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.