Thursday, December 20, 2012

Having problems with getOffsetWidth() accuracy?

Hi,

I'm using firefox 17. I'm trying to measure the width of a FlowPanel instance. It seems to always be off by about 5 or 6 pixels. I'm doing it like this:

    FlowPanel fp = new FlowPanel();
    fp.getElement().getStyle().setProperty("maxWidth", 300);
    fp.getElement().getStyle().setProperty("fontSize", 18);
    fp.getElement().setInnerText("hello");

    RootPanel.get().add(fp);
    int width = fp.getOffsetWidth(); // <-- not accurate

Is this not the correct way to do it? Is there some additional layout pass that happens after adding a panel which alters its size?

Thanks

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/gtWCTw45bNIJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment