使 JNLP Web-Start 小程序可调整大小
我们有一个小程序用于在浏览器中运行我们的应用程序,但我们还提供了 JNLP Web 启动选项。当网络启动窗口启动时,它不能调整大小或最大化,我们希望使之成为可能。
我最初认为这是 JNLP 文件中的一个简单设置,但现在我不确定。我应该如何处理这个问题?
We have an applet used to run our app in-browser, but we also provide a JNLP web-start option. When the web-start window launches, it is not resizable or maximizable and we want to make this possible.
I initially thought it be a simple setting in the JNLP file but now I'm not sure. How should I be approaching this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
JNLP 中没有任何设置可以满足可调整大小的小程序查看器(JWS 使用它来显示浮动小程序)。
OTOH 一点点黑客技术可能会让你到达那里。我记得很久以前就这样做过。我认为从记忆中它基本上涉及
getParent()
循环直到null
,之前的最后一个组件是JFrame
。一旦获得了对框架的引用,就可以调用setResizable(true)
。事实上,(考虑)您也可以查看
JComponent.getTopLevelAncestor()
用于获取对根框架的引用。 AFIU 当我尝试实验时,这种方法并不存在。 (是的,很久以前就是这样。)当然,总体上更好的策略是创建混合应用程序/小程序。将小程序嵌入到浏览器中,并通过 JWS 启动框架。这提供了对 GUI 的完全控制。
There is no setting in the JNLP that caters for a resizable applet viewer (which is what JWS uses to show floating applets).
OTOH a little bit of hackery might get you there. I can recall doing this some (long) time ago. I think from memory it basically involved
getParent()
in a loop untilnull
, the last component before that was aJFrame
. Once you have a reference to the frame, you can callsetResizable(true)
.In fact, (considers) you might also look into
JComponent.getTopLevelAncestor()
for getting a reference to the root frame. AFIU that method did not exist when I tried the experiment. (Yes, it was that long ago.)Of course, an overall better strategy is to create a hybrid application/applet. Embed the applet into a browser, and launch the frame by JWS. This provides full control over the GUI.
下面是我在
init
方法末尾添加的一些代码,这些代码使我的小程序可调整大小。我的类扩展了JApplet
。希望这有帮助。
Here's a bit of code I added at the end of my
init
method that made my applet resizable. My class extendsJApplet
.Hope this helps.
尽管已经是 2022 年了,我仍然遇到这个问题。
不,我不是开发团队的成员,也无法访问源代码。
我所做的是每次下载 JNLP 时都使用 shell 脚本将 JNLP 文件中的窗口大小更改为我喜欢的大小。
它不可调整大小,但我当然可以在 shell 脚本中更改窗口大小并重新启动 JNLP 应用程序。
I still have this problem even though is 2022.
No, I am not part of the dev team and I do not have access to source code.
What I did was use shell script to change the window size in the JNLP file to my liking every time I downloaded the JNLP.
It's not resizable but of course I can change window size in shell script and restart JNLP application.