• 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

to avoid grayed-out version of jbutton

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79239
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Don't know. Sorry.

Anybody else?
 
Marshal
Posts: 28226
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A small code example would help.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic