Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JButton "focus" issue

 
Bob Ruth
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • 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
 
Bill Johnston
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • Quote
  • Report post to moderator
Wait a minute ... on second thought ... why does requestFocus() not work?
 
Brian Cole
Author
Ranch Hand
Posts: 924
1
  • Mark post as helpful
  • send pies
  • 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.
 
We begin by testing your absorbancy by exposing you to this tiny ad:
the new thread boost feature: great for the advertiser and smooth for the coderanch user
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!