Search code examples
gwttextboxwidthpixel

GWT - how to precisely set rendered width of TextArea in pixels?


I need to render a TextArea in an exact pixel width for the special purposes of my GUI.

When I set its width to "250px", it comes out as 256px.

Is there a way to override this behavior so I can render it as 250px exactly?


Solution

  • When you use setWidth(), you're effectively setting the element's content width.

    To get the offset width use UIObject#getOffsetWidth(). This will return the width including padding and border (but not margins).

    References on W3C