Results 1 to 6 of 6

Thread: Use of JOptionPane class

  1. #1
    Join Date
    Dec 2009
    Posts
    38

    Use of JOptionPane class

    Hi All,

    I need you help to solve one of my query which is related to the inbuilt classes of the advanced java. I am unable to understand the exact use of the JOptionPane class. I know this is one of the important class of java swing. If you know anything about the JOptionPane class of java then please share it with me. I would really appreciate you help if you provide suitable example for this java class.

  2. #2
    Join Date
    May 2008
    Posts
    2,012

    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.

  3. #3
    Join Date
    Apr 2008
    Posts
    2,005

    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);

  4. #4
    Join Date
    Oct 2005
    Posts
    2,393

    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)

  5. #5
    Join Date
    May 2008
    Posts
    2,389

    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);
    
      }
    }

  6. #6
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Use of JOptionPane class

    Hi,

    Below I have given some of the constructors of JOptionPane class of java:
    1. JOptionPane(Object msg1, int msgType, int optionType, Icon icn, Object[] options, Object initialVal)
    2. JOptionPane(Object msg1, int msgype, int optionType, Icon icn, Object[] options)
    3. JOptionPane(Object msg1, int msgType, int optionType, Icon icn)
    4. JOptionPane(Object msg1, int msgType, int optionType)
    5. JOptionPane(Object msg1, int msgType)

Similar Threads

  1. Replies: 8
    Last Post: 08-10-2011, 11:06 PM
  2. How Can I Change the background Color Of A JOptionPane?
    By Adrina_g in forum Software Development
    Replies: 5
    Last Post: 27-01-2010, 09:41 AM
  3. JOptionPane.showInputDialog size list
    By New ID in forum Software Development
    Replies: 5
    Last Post: 19-01-2010, 12:06 PM
  4. Joptionpane in java
    By Xmen in forum Software Development
    Replies: 2
    Last Post: 14-11-2009, 12:20 PM
  5. Good news for CBSE CLASS X & CLASS IX - visit learnnext
    By surya_expert in forum Education Career and Job Discussions
    Replies: 0
    Last Post: 13-12-2008, 12:09 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,750,912,133.99905 seconds with 16 queries