text alignmnet in textfield

I would like to right justify textfields.
I have tried gridLayout.setComponentAlignment( field, Alignment.MIDDLE_RIGHT );

But the text is not right aligned.

I mean the text inside the textfield

setComponentAlignment is used to align the whole component inside the layout. E.g. if you have a wide component beside a smaller component, the smaller component can be aligned to the right side of the wider component.

For text alignment, you need CSS. Add a custom style name for the text field (e.g. addStyleName(“align-right”)), and then in your custom theme CSS, write the following:

.v-textfield-align-right {
   text-align: right;
}

That should do it.