Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

JButton.setEnabled(false) doesn't show as greyed off

Status
Not open for further replies.

dtqui

Programmer
Sep 25, 2000
62
0
0
SG
Hi,

I have this menu with consist of several JButtons which contains ImageIcon to represent them.

At a click of any of the buttons, the respective screens will show and the menu buttons will be disabled.

However, the behaviour of my menu disabling buttons is weird, sometimes it disable all, sometimes, a few of them only. Another weird thing is, the buttons are actually disabled(i can't click on it) but the image is still shown as enabled.

Anyone came across this?
 
Is it just a problem with the screen not being redrawn? Do you have to explicitly call paint() or refresh() or something?
 
You could always switch the text of the button using an HTML formatted string to be greyed out:
<font color=grey>Button Text</font>

It should grey out on it's own if you setEnabled(false); ... But I've had this problem a couple of times as well.
 
Hi all,

I've solved the problem, thanks to stevexff. I just added a repaint() after I disabled the buttons.

jstreich, I think you misunderstood. It's pure image on the button which didn't get greyed off, not the text.

stefanwagner, according to Java Tutorial at the buttons can be disabled using setEnabled(false).

Thanks for replying. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top