Link to home
Start Free TrialLog in
Avatar of Robert Silver
Robert SilverFlag for United States of America

asked on

How to properly obtain screen dimensions in GWT?

How do I properly obtain screen dimensions for the RootPanel of the browser screen?
Would using say:
com.google.gwt.user.client.ui.HTML
and calling:
e.g
HTML htmlObj;
int myHeight= htmlObj..getOffsetHeight();
int myWidth=htmlObj.getOffsetWidh();

I would appreciate any help here ???
Avatar of Robert Silver
Robert Silver
Flag of United States of America image

ASKER

Note when I try to obtain the Height offset
e.g  rootPanel.getOffsetHeight()   I get 0 . Why? How do I obtain the actual screen height potentially?? A bit more research shows that this is a programmable number
e.g if I rootPanel.setSize("100%","2000px");   the getOffsetHeight uses that size.
By default I would have thought the default getOffsetHeight() would be the physical size possible of a  graphic on a given screen e.g Android might be 400px by 640px maybe and
I could then get those values. How might I get the physical for device height in pixels then?
ASKER CERTIFIED SOLUTION
Avatar of Robert Silver
Robert Silver
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well I found out something else everyone here should know. Microsoft Internet Explorer does not work well with Absolute positioning within GWT. Please let me know if you find a way to use Absolute positioning. I ultimately set Absolute positioning with the statement:
rootPanel.getElement().getStyle().setPosition(Position.ABSOLUTE);
Then get the the Offsets e.g
getOffsetHeight() and getOffSetWidth() and they both return proper values to be used,however, I must set rootPanel.getElement().getStyle().setPosition(Position.RELATIVE);
and then provide relative positioning to solve the cross browser needs.
Note GWT is no longer supported by Firefox 14 latest addition at the time of this writing nor is it supported by Opera or Safari. Only IE and Google Chrome and the Chrome is a pain to install GWT now. drag and drop nonsense has to be done in a prescribed maner due to some ill conceived security constraints.
Just updating my previous solution.