Re: Use of JOptionPane class
Hello friend,
A JOptionPane class of java makes it easy to pop up a standard dialog box that prompts users for a value or informs them of something. While the JOptionPane class may appear complex because of the large number of methods, almost all uses of this class are one-line calls to one of the static showXxxDialog methods. The basic appearance of one of these dialog boxes is generally similar to the picture at the right, although the various look-and-feels are ultimately responsible for the final result.
Re: Use of JOptionPane class
Example of JOptionPane class:
Code:
public JOptionPane()
JOptionPane optionPane1 = new JOptionPane();
public JOptionPane(Object msg)
JOptionPane optionPane1 = new JOptionPane("Message");
public JOptionPane(Object msge, int messageType)
JOptionPane optionPane1 = new JOptionPane("Message", JOptionPane.WARNING_MESSAGE);
public JOptionPane(Object msge, int messageType, int optionType)
JOptionPane optionPane1 = new JOptionPane("Question?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION);
public JOptionPane(Object msge, int messageType, int optionType, Icon icon)
Icon printerIcon = new ImageIcon("yourFile.gif");
JOptionPane optionPane1 = new JOptionPane("Question?", JOptionPane.QUESTION_MESSAGE, JOptionPane.YES_NO_OPTION, printerIcon);
Re: Use of JOptionPane class
Hi,
Following are some methods of JOptionPane class of java:
- createInternalFrame(Component parentCmpt, String title)
- getDesktopPaneForComponent(Component parentCmnt)
- getFrameForComponent(Component parentCmnt)
- createDialog(Component parentCmnt, String title)
- setInitialSelectionValue(Object newVal)
Re: Use of JOptionPane class
Please review following java code to know about the use of JOptionPane class:
Code:
import javax.swing.JOptionPane;
public class JOptionPaneSample
{
public static void main(String[] adf)
{
String input1 = JOptionPane.showInputDialog(null, "Enter Input:", "Dialog for the Input",
JOptionPane.WARNING_MESSAGE);
System.out.println(input1);
}
}
Re: Use of JOptionPane class
Hi,
Below I have given some of the constructors of JOptionPane class of java:
- JOptionPane(Object msg1, int msgType, int optionType, Icon icn, Object[] options, Object initialVal)
- JOptionPane(Object msg1, int msgype, int optionType, Icon icn, Object[] options)
- JOptionPane(Object msg1, int msgType, int optionType, Icon icn)
- JOptionPane(Object msg1, int msgType, int optionType)
- JOptionPane(Object msg1, int msgType)