I am porting my desktop Swing application to an applet. The following code works perfect for JFrame
entity to set a maximum available window size, considering a task bar.
GraphicsEnvironment env = GraphicsEnvironment.getLocalGraphicsEnvironment();
Rectangle bounds = env.getMaximumWindowBounds();
frame.setMaximizedBounds(bounds);
frame.setPreferredSize(bounds.getSize());
frame.setLocation(0, 0);
In Eclipse Run Configurations -> My Applet -> Parameters I can select Width and Height or if applet is run from browser one would have to do:
<applet code="myJApplet" width="800" height="480">
But I would like to be able to set size dynamically depending on screen resolution. How would it be possible?
I have found it here: http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/
<script type="text/javascript">
<!--
var w=window,d=document,e=d.documentElement,g=d.getElementsByTagName('body')[0],x=w.innerWidth||e.clientWidth||g.clientWidth,y=w.innerHeight||e.clientHeight||g.clientHeight;
//-->
</script>