• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JDialogBox

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I am very much new to swing and awt. I have a simple problem with my dialog box. (JDialogBox.showErrorMessage(....)) I am using dialog box to pop-up error messages. but when the user uses mouse to click on yes or no then even is generated correctly, but when the user hit enter key after focusing on NO , still it is generating the event for YES. something wrong with my implementation ? or this is expected result ? plz help me.
 
Ranch Hand
Posts: 133
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi
maybe there is something wrong with the events ..maybe there is no keyboard event for the no button,,check the events again
Good luck
Maha
 
Ranch Hand
Posts: 51
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To show error / warning messages use JOptionPane.
They are helpful,
No need to create you own Dialog
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I was talking about the JOptionPane only. when I used the JOptionPane to pop up error message that is taking Yes value when I hit enter even if the focus is set on No. I did not create any DialogBox my own, I just used JOptionPane to popup a message. I did not add any event for it. JOptionPane is responding perfeclty when I use mouse click, even when I use space also it is responding correctly. But when I hit enter key it is giving only the Yes value even if the focus in set on No. This is what the problem is, any idea ?
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was talking about this code fragment.


This is returning same value on Enter Key regardless of the focus. But in the mouse click it is returning the correct value. Please give your valuable comments.
[ August 18, 2005: Message edited by: Sanju Thomas ]
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please some one help me.
 
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In the app below the 'enter' key always seems to invoke the option that is the
'initialValue' in the dialog, ie, the button that is initially selected. This only seems to
work for the metal plaf. The option designated as the 'initialValue' in the constructor seems
to function like a default command button for the dialog. See paragraph four and Table 8
under the 'Keyboard Navigation and Activation' section of page 6 in the
'Java Look and Feel Guidelines'. Also the 'Default Command Buttons' section on
page 8.

ps — try using the 'spacebar' to activate the buttons instead of the 'enter' key.
[ August 19, 2005: Message edited by: Craig Wood ]
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thank you Craig, but Craig, is there any way to override this feature.
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
is this what you're trying to do?

 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Craig , Thank you for replay .

I was aware that it will work with Window look and feel, but I was asking that is there any way to get this feature in metal look and feel.

if there is some solution please send me a replay.
 
Craig Wood
Ranch Hand
Posts: 1535
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The defaultButton behavior seems to come from one or two places in the
javax.swing.plaf.basic.BasicOptionPaneUI class. The block under the
"counter == initialIndex" test adds an AncestorListener to the first JButton which sets it
as the defaultButton each time the button is made visible. I could not find a way to
remove/prevent the resulting action.

This minimal subclass of BasicOptionPaneUI seems to avoid the defaultButton issue. I tried
to map the "Enter" key to the optionPane JButtons to work like they do with the "Space"
bar/key. Seems to work okay so far.
 
Sanju Thomas
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Craig, I could not give a test on it, bcz my machine is loaded with 1.4, I can't change in this point bcz project is on the last phase. I will test it and give my update.

Thank you very much for spending some time for me.
 
Eliminate 95% of the weeds in your lawn by mowing 3 inches or higher. Then plant tiny ads:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic