Hi,
I need to get the height and width of browser’s client.
The following code gives infos about the name of the browser, but doesn’t give the dimensions.
Where i am wrong ?
public class Launcher extends Application {
@Override
public void init() {
Window main = new Window("Hello window");
setMainWindow(main);
main.addComponent(new Label("Hello World!"));
ApplicationContext context = this.getContext();
if (context instanceof WebApplicationContext) {
String userAgent = ((WebApplicationContext)this.getContext()).getBrowser().getBrowserApplication();
System.out.println("appli context : "+userAgent);
int a = ((WebApplicationContext)this.getContext()).getBrowser().[color=#e80d40]
getScreenHeight();
[/color]
int b = ((WebApplicationContext)this.getContext()).getBrowser().[color=#e80d40]
getScreenWidth();
[/color]
boolean boo = ((WebApplicationContext)this.getContext()).getBrowser().isFirefox();
System.out.println("Height : "+a+", Width: "+b+", isfirefox : "+boo);
}
}
}
Result :
appli context :
Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; … .NET4.0E; BRI/2; InfoPath.3)
Height: 0, Width: 0
,
isfirefox : false