Forums Register Login

to avoid grayed-out version of jbutton

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
We need more details, please. A button usually goes grey if disabled with setEnabled(false).
+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
Don't know. Sorry.

Anybody else?
+Pie Number of slices to send: Send
A small code example would help.
+Pie Number of slices to send: Send
"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.
+Pie Number of slices to send: Send
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.
Everybody's invited. Even this tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 1845 times.
Similar Threads
Highlight the search field in a text area -----HELP required URGENT
Problem in Swing
How to disable buttonGroup
How to disable buttonGroup
Jbutton within Jtable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 18:28:38.