JOptionPane.showMessageDialog


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: JOptionPane.showMessageDialog

  1. #1
    Join Date
    Sep 2002
    Posts
    9

    JOptionPane.showMessageDialog

    Hi!

    I need a little help .....

    I have a problem with the method showMessageDialog belonging to JOptionPane's class.
    I used this method to menage an event (in particular a button event). This is the code I used:

    public void actionPerformed(ActionEvent e)
    {
    if (e.getActionCommand() == "View")
    {
    String output = "Credits: " + "200" ;

    JOptionPane.showMessageDialog(null, output , "Status", JOptionPane.INFORMATION_MESSAGE);

    System.exit(0);
    }
    }

    The result is an empty pane with the only button "OK".
    Neither the String I passed as parameter nor the icon "I" (because it is an INFORMATION_MESSAGE the icon is just an "I") was displayed....
    So I tried to run the exclusive JOptionPane.showMessageDialog code in another new file and it works correctly....

    What do I wrong?

    Thanks for your support.
    Bye!!

  2. #2
    Join Date
    Sep 2002
    Posts
    2
    Did you try to use EventQueue.invokeLate() so that all events can be executed before showing the dialog:

    final String output = ...
    EventQueue.invokeLater(new Runnable()
    {
    public void run()
    {
    JOptionPane.showMessageDialog(...)
    }
    });

    GreatValue

  3. #3
    Join Date
    Sep 2002
    Posts
    9
    Hi!
    thanks for your reply!

    well, I tried to do as you said by copying your code inside my project but unluckely it still doesn't work....

    I thought that maybe I wrong the first parameter I pass to the method (which is actually null), but it didn't work also with "this" parameter...

    If you'll have some idea let me know, thanks again!
    BYE!
    mirjam

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center