jQuery in Action, 2nd edition*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes JOptionPane question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "JOptionPane question" Watch "JOptionPane question" New topic
Author

JOptionPane question

Axel Leucht
Greenhorn

Joined: Jan 19, 2009
Posts: 21
I'm currently testing my URLyBird assignment on a SUN Solaris 10 box for the first time and have an obscure problem with my JOptionPane.

The user is presented a JOptionPane to input the customerID value. My JOptionPane can be also invoked from the keyboard, so the invoking button has an appropriate MNEMONIC_KEY defined.
But this works only for he first time! The second time I have to give focus to the applicction in order to have the mnemonic work as expected. Here are the problematic code snippets. Alas, everything works correct under Windows. OnSolaris it only works when I let set focus to the main window which is the owner JOptionPane.

Does anyone have a clue why it is not working as expected or how to proceed?



Regards

SCJP, SCJD
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2383
    
    7

I'm not quite sure if I get your question. A JOptionPane is a form of JDialog. So if your BookAction displays a JOptionPane then you shouldn't need to set focus or anything.

However, if you display a JOptionPane outside your BookAction then somehow have the BookAction gets this input ...


K. Tsang JavaRanch SCJP5 SCJD/OCM-JD OCPJP7 OCPWCD5
Axel Leucht
Greenhorn

Joined: Jan 19, 2009
Posts: 21
Indeed, my post might be unclear, so I'm trying to make myself a little clearer.

I'm opening a JOptionPane-based input dialog from within my actionPerformed method of my button's action class. The button's action can be invoked from the keyboard successfully only one time. The second time I type the mnemonic, nothing happens. It should, again, display the JOptionPane, right?

I wonder if some other component has the focus, because when I insert the call the have the mainwindow request the focus, I can successfully display the JOptionPane multiple times by typing the mnemonic. And I wonder why this happens only under Solaris and works ok in Windows.

I hope that my problem is now better described.
K. Tsang
Bartender

Joined: Sep 13, 2007
Posts: 2383
    
    7

Interesting looks like a Solaris problem haha.

Once you enter customer ID in the JOptionPane and click OK the focus should be at the main window with the table updated and all right? If that's the case, as long you are in the main window then you have the focus to trigger any actions.

If this is not the case, you should regroup your actions. If it is then its your action problem. Maybe posting your code where the book action is trigger and the actionPerformed of the book action may help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JOptionPane question