How can i change opacity on caption and content when textfield.setEnabled(false) ?


You can remove the “dimming” of disabled components with custom CSS:

.v-disabled {
   opacity: 1;
   filter: none;

If you only need it on some fields, you can add a custom style name for those fields, and reset the opacity for them:

// Java

// CSS
.my-disabled {
   opacity: 1;
   filter: none;

That should do it.

Thank you Jouni, but the caption of the TextField still opacity (like disabled) .

I’d like to change the opacity(caption and content) for some fields, not all.

You have to call addstylename on those fields that you call setEnabled(false) and then again remove it with removeStyleName when you call setEnabled(true).

You could extend the TextField to do this automatically.

public class MyTextField extends TextField{
  public void setEnabled(boolean enabled){


It should also be possible to tag your components with a static style name that tells what should happen when they are disabled, and then use a CSS rule that requires both that style name and .v-disabled to be present. This way, there should not be need to change style names on the fly in your application code.

This would be optimal, but unfortunately it is impossible to achieve in IE6. If you don’t need to support that, then this approach is the best.

You’re right, I remembered one thing wrong. To fix the captions as well, you need to add the following CSS:

.v-caption-my-disabled {
    opacity: 1;
    filter: none;

Thank you again Jouni, it works fine !