Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JOptionPane question

 
Axel Leucht
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?


 
K. Tsang
Bartender
Posts: 3397
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ...
 
Axel Leucht
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3397
13
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic