如何为JApplet的设置最大可用大小? [英] How to set maximum available size for JApplet?

查看:276
本文介绍了如何为JApplet的设置最大可用大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我端起我的桌面Swing应用程序到一个小程序。下面code工作完美的的JFrame 实体设置最大可用的窗口大小,考虑到任务栏。

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);

在Eclipse中运行配置 - >我的小程序 - >参数我可以选择的宽度和高度,或者applet从浏览器中运行一个必须做的:

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?

推荐答案

我已经在这里找到:的 http://andylangton.co.uk/articles/javascript/get-viewport-size-javascript/

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>

这篇关于如何为JApplet的设置最大可用大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆