File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Riffle Chris
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2473
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
and then that text value is cleared (by me calling setText(null),


Maybe try:

 
Riffle Chris
Greenhorn
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 27
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4632
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
windows L&F (as that was part of the stated problem in the subject line)
vista
1.6.0_18
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic