This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

to avoid grayed-out version of jbutton  RSS feed

 
Shankar Arumugam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi to all,
I am using two JText field and one JButton .One of the text field should accept numeric values.while clicking the button in the event i am parsing the text field value to integer if it throws NumberFormatException i am catching the exception and displaying alert message.Upto this every thing works fine but the button turns to grayed - out version.I don't know how to avoid this effect. Help me out to solve the problem
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We need more details, please. A button usually goes grey if disabled with setEnabled(false).
 
Shankar Arumugam
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not using any where in my code setEnabled(false).I had written the focusLost event for the text field and doing the validation in the event.I am maintaining the focus in the text field itself.for the button i had written different event but that event is not invoked and the button is turning to grey
 
Campbell Ritchie
Marshal
Posts: 55717
163
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't know. Sorry.

Anybody else?
 
Paul Clapham
Sheriff
Posts: 22502
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A small code example would help.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"Grayed out" can also have a different meaning.
When you "click" a button it is actually pressed and "un-pressed" at the end of actionPerformed. (It is technically called "armed" in the pressed state,if I am not mistaken.)

So, my guess would be:
1) Maybe, your action performed is not returning and going in some infinite loop. As you haven't posted any code, it is difficult to tell.
2) Ok. This is probably a stupid guess on my part, but you are using JToggleButton instead of JButton

Like Campbell said, we need more details to help you out.
 
Suraj Chandran
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If only the button is grayed
During painting of the button, some exception gets thrown, and hence the button is getting grayed. But the entire exception doesent get gray because the exception will be caught by EDT and it will continue painting. Also note that even in the above condition the entire app can go gray, but it depends on the position of the button.

If the entire app is getting gray
A no brainer EDT is stuck doing something miserable. Dont mess with EDT, it will disappoint you really bad. Debuggin I gues must be easy.

Without any code, we can't give you any better.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!