Results 1 to 4 of 4
  1. #1
    bristow is offline Member
    Join Date
    Jul 2011
    Posts
    1
    Rep Power
    0

    Default JOptionPane.showOptionDialog(null....) does not show up the dialog at all.

    Hello guys,

    I used JOptionPane.showOptionDialog(null,....). Null as first parameter indicates that the parent for this dialog is not known.

    My question here is if I run the code from eclipse, sometime I see the dialog coming under the main window and sometimes over the main window of my application (centered).

    However, if I run the application from release build (Made local build using eclipse and installed the application), the dialog does not come up at all and the application freezes. It looks like the application is blocked due to dialog not coming up.

    Can you please tell me why this difference when run from eclipse and from build?

    Help will be appreciated.

    Thanks,
    bristow

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,196
    Rep Power
    19

    Default

    1. Is your 'main window' set to always-on-top?
    2. Does your code respect Swing's single threaded rule?
    3. What problem do you have in parenting the dialog appropriately? A null parent is usually passed only when there isn't another window visible.

    Oh, and
    Can you please tell me why this difference when run from eclipse and from build?
    Don't waste time with irrelevant stuff that won't help solve your problem.

    db

    edit
    the dialog does not come up at all and the application freezes. It looks like the application is blocked due to dialog not coming up.
    More likely the dialog is being shown behind the frame (in zOrder)
    Last edited by DarrylBurke; 07-27-2011 at 10:20 AM.

  3. #3
    stchman's Avatar
    stchman is offline Member
    Join Date
    Apr 2011
    Location
    Saint Louis, Missouri
    Posts
    97
    Rep Power
    0

    Default

    I just tried this using Netbeans and Eclipse:

    Java Code:
    package joptiondialog;
    
    import javax.swing.JOptionPane;
    
    /**
     *
     * @author BN
     */
    public class JOptionDialog {
        public static void main(String[] args) {
            JOptionDialog m = new JOptionDialog();
            m.showDialog();
        }
        
        public void showDialog() {
           JOptionPane.showMessageDialog( null, "Hello, this is a message.", "Information", JOptionPane.INFORMATION_MESSAGE );         
        }
    }

  4. #4
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    Your code doesn't control the positioning of the dialog, on top, on bottom as Darryl explains to you. So the dialog will appear on top by default when you run with NetBeans (I hope the same with Eclipse). You may be click on other window on your desktop before the message box pops up, then the message will appear at the bottom. That's not relevant with Java, controlled by the OS itself.

Similar Threads

  1. Help with closing JOptionPane.showOptionDialog
    By Rafik in forum New To Java
    Replies: 3
    Last Post: 06-07-2011, 06:42 AM
  2. JOptionPane dialog (Localizing)
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 03-14-2008, 11:36 AM
  3. Replies: 0
    Last Post: 12-17-2007, 09:46 AM
  4. JOptionPane - message dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 09:11 AM
  5. JOptionPane - input dialog
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-17-2007, 09:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •