Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

Disabled components

 
Ranch Hand
Posts: 455
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi. I was wondering how I could change the background and foreground on a component that has been disabled.
I have run in to a couple of problems.
I have a JTextField disabled and I am able change the background color, but I can't seem to get the foreground color to change??
I also have a JComboBox that I have disabled. I can change the background to white, but the list part of it is still grey. How do I change the list part of the component and the foreground as well?
Any help would be appreciated!
Thanks.
 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Try setDisabledTextColor() from JTextComponent for the text field.
I'm not sure what you mean by the "list part" of the combo box. The little arrow/button thingie? I didn't think the actual list would pop up if the combo box was diabled.
Bill
 
Ranch Hand
Posts: 338
1
Mac Eclipse IDE Safari
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Your answer to the JTextfield problem was just what I needed. However is it possible to do the same sort of thing with the text element of a JSpinner ?

Thanks

Dave
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
JTextField tf = ((JSpinner.DefaultEditor)spinner.getEditor()).getTextField();
tf.setEnabled(false);
tf.setDisabledTextColor(UIManager.getColor("TextField.foreground"));
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic