• 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

JButton "focus" issue

 
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have written a little tool ( and when I say little I mean little ) that just supplies a window with three JButtons on it (Restart X, Reboot, Shutdown). It is just a comfort tool for the maintenance folks here. When you select a button a confirmation box pops up over it with two more JButtons, Yes and No. Click Yes, and you perform the function. Click no and the confirmation box disappears and you go back to what you were doing. No big deal.

But my customer wants me to set things up where the No button is the default button. I have done that. It works....as expected.... I just have one problem. When I set the DefaultButton to the NO button, I get a double line around the button like you should, the button looks slightly more pronounced like it should, and when I mouse into the window and hit Enter it performs the No function.....again like it should.

So what is my problem?

The button on the left is Yes, and No is on the right. The word Yes has a light square around it that moves to the No button ONLY when I click the No button. THEY seem to think that the square is indicative of focus and would like to see it come up on the No button. I have not been able to find a call in the API that will move that square. It comes up on the first button no matter what I do.

Is there a way to move that square to another button? It doesnt seem to have anything to do with DefaultButton, or setting the focus, I cant find anything.

Anybody got any ideas?

I'd appreciate a "kick" here...

Bob
 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Have you looked into this: http://java.sun.com/developer/JDCTechTips/2002/tt1022.html#2

???
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wait a minute ... on second thought ... why does requestFocus() not work?
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wait a minute ... on second thought ... why does requestFocus() not work?
 
Author
Posts: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bob Ruth:
Is there a way to move that square to another button? It doesnt seem to have anything to do with DefaultButton, or setting the focus, I cant find anything.

Anybody got any ideas?



Well, you should be able to turn off the square completely with setFocusPainted(false), but that would mean that it does have something to do with focus.
 
reply
    Bookmark Topic Watch Topic
  • New Topic