JTextField background color on enable/disable
Asked Answered
B

1

3

i changed the background color of my JTextField to black when it is disabled. I do this using the UIManager and this property TextField.disabledBackground, that i set at application start up. I would like to know how can i change the background color when the JTextField is enabled again ? Thank you.

Byers answered 24/5, 2011 at 17:58 Comment(0)
F
3

Have a look at http://tips4java.wordpress.com/2008/10/09/uimanager-defaults/ Run the webstart app there, or download the code and run that utility yourself. What you want might be "TextField.background", but armed with the list of properties and defaults, you'll find the right one I bet.

Fabricate answered 24/5, 2011 at 19:24 Comment(2)
Ok so i can do UIManager.put("TextField.background", colorBackground); on some action that will enable the textfield ?Byers
Setting values in UIManager changes the colors used by Swing to paint the component. So if you set "TextField.background" it will change all JTextField components in your application, depending on the Look and Feel you are using. If you only want to change one JTextField, you'll need to use field.setBackground(someColor) in whatever event makes sense to you. I thought that because you were using UIManager for the disabledBackground that you wanted to change all fields the same, but now I'm wondering if I misunderstood.Fabricate

© 2022 - 2024 — McMap. All rights reserved.