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

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

问题描述

我正在将我的桌面 Swing 应用程序移植到小程序.以下代码非常适合 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 运行配置 -> 我的小程序 -> 参数中我可以选择宽度和高度,或者如果小程序是从浏览器运行的,则必须这样做:

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/

<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天全站免登陆