Setting a swing component to not editable...

Hi,

is it possible to set a swing component (e.g. JTextField) to not editable but on the other side the component should not be displayed in the typical grey looking style?

The background is, I' ve a lot of text fields on my page which all just display data - the user should not be able to edit any of these text fields - but I'd like them to be displayed as a normal (editable) white text field.

Any ideas on how to achive this?

Thanks in advance

- Stephan

[497 byte] By [Jacklera] at [2007-11-27 8:31:13]
# 1

I think it's better to create a class which extends JTextField, and add some color modifications in its constructor or setEditable() method.

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/text/JTextComponent.html#setDisabledTextColor(java.awt.Color)

http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/JComponent.html#setBackground(java.awt.Color)

Arash.Shahkara at 2007-7-12 20:26:37 > top of Java-index,Desktop,Core GUI APIs...