This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
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


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.
 
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Setting color for non-enabled component
 
It's not a secret anymore!