permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes ? JTextField disabled bg color sometimes grey & sometimes white on Windows Lk/Feel !?!? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "? JTextField disabled bg color sometimes grey & sometimes white on Windows Lk/Feel !?!?" Watch "? JTextField disabled bg color sometimes grey & sometimes white on Windows Lk/Feel !?!?" New topic
Author

? JTextField disabled bg color sometimes grey & sometimes white on Windows Lk/Feel !?!?

Riffle Chris
Greenhorn

Joined: Feb 18, 2009
Posts: 27

Hey everybody good morning,

When I call setEnabled(false) on my JTextFields, sometimes their background color is grayish, and sometimes their background color is white.



Their value for the text is always null in each case. I'm using the Windows Look and Feel.

Guess I could do a hack to manually set the colors(would like the grayish color),... but was wondering if this behavior was known,... or if I'm missing something.

Thanks for any help!
Riffle Chris
Greenhorn

Joined: Feb 18, 2009
Posts: 27
Still would love some help but pretty sure I noticed some more interesting behaviour.

If a value has not yet been set on the text field(by the user or typing or by me calling setText("hey") ), then I can call setEnabled(true/false) all day long and it will toggle the background color between grayish(disabled) and white(enabled).

BUT as soon as a value is set for the text field(user typing or me calling setText), and then that text value is cleared (by me calling setText(null), all successive calls to setEnabled(false) will render the background to white instead of gray(desired).

Thanks!
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2177
    
    7
and then that text value is cleared (by me calling setText(null),


Maybe try:

Riffle Chris
Greenhorn

Joined: Feb 18, 2009
Posts: 27
Rob Camick wrote:
and then that text value is cleared (by me calling setText(null),


Maybe try:




Thanks, that does Not work either


Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
worked OK for me

> BUT as soon as a value is set for the text field(user typing or me calling setText),
> and then that text value is cleared (by me calling setText(null),
> all successive calls to setEnabled(false) will render the background to white instead of gray(desired).

mine are gray
Riffle Chris
Greenhorn

Joined: Feb 18, 2009
Posts: 27
Michael Dunn wrote:worked OK for me

> BUT as soon as a value is set for the text field(user typing or me calling setText),
> and then that text value is cleared (by me calling setText(null),
> all successive calls to setEnabled(false) will render the background to white instead of gray(desired).

mine are gray



Thanks Michael - I was curious what Look and Feel, operating system and jvm version you're using.
Michael Dunn
Ranch Hand

Joined: Jun 09, 2003
Posts: 4632
windows L&F (as that was part of the stated problem in the subject line)
vista
1.6.0_18
 
wood burning stoves
 
subject: ? JTextField disabled bg color sometimes grey & sometimes white on Windows Lk/Feel !?!?