aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Setting color for non-enabled component Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting color for non-enabled component" Watch "Setting color for non-enabled component" New topic
Author

Setting color for non-enabled component

dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Hi all,

I'm trying to set the foreground color of a JComponent (particularly, a JTextField) when that JComponent is not enabled. The default behavior for SWING, of course, is to grey-out the text. Is there any way for me to override that grey color? Using setForeground(), either before or after the setEnabled() call, doesn't seem to do anything.


Dave Taubler<br />Specializing in <a href="http://taubler.com/articles/" target="_blank" rel="nofollow">Java and Web Development</a>
dave taubler
Ranch Hand

Joined: May 15, 2001
Posts: 132
Okay, two second after I posted that, I went back to the JavaDoc page and saw TextComponent.setDisabledTextColor(). Amazingly, that did the trick.
 
 
subject: Setting color for non-enabled component
 
Similar Threads
JTable (Size and Colour)
how to change the color of Scrollpane
enabled, but non-editable combobox foreground color
setBackground(); isn't working
Issues with disabled select boxes in IE