![]() ![]() ![]() JLabel label2 = new JLabel("Are you sure you want to continue?") tHorizontalAlignment(SwingConstants.CENTER) tVerticalAlignment(SwingConstants.BOTTOM) JLabel label1 = new JLabel("This file requires administrator rights.") ImageIcon icon = new ImageIcon("src/images/lock64.png") The showConfirmDialog() will bring up a dialog with the options Yes, No and Cancel and the title “Select an Option”: Icon – The last parameter is an Icon that is displayed inside the dialog and overrides the default MessageType icon.The different MessageTypes for JOptionPane, are: int – The next int is the MessageType. ![]() The different OptionTypes for JOptionPane, are: int – The int that follows the String is the OptionType.String – The third parameter is a String placed as the title of the confirmDialog window.(In some older versions of Java you might get a compiler error when using primitive types directly) Object – The second parameter can be any Object.Component – The first parameter is a Component which determines the Frame in which the dialog is displayed if null, or if the parentComponent has no Frame, a default Frame is used.The showConfirmDialog() can be called using the following combinations of parameters:Ĭomponent, Object, String, int, int, Icon This method is a quick and easy way to get user input by asking a confirming question, like yes/no/cancel. This is a review of the showConfirmDialog() method of JOptionPane Class.
0 Comments
Leave a Reply. |