使 JNLP Web-Start 小程序可调整大小

发布于 2025-01-02 12:26:06 字数 141 浏览 4 评论 0原文

我们有一个小程序用于在浏览器中运行我们的应用程序,但我们还提供了 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

向地狱狂奔 2025-01-09 12:26:06

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 until null, the last component before that was a JFrame. Once you have a reference to the frame, you can call setResizable(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.

黎歌 2025-01-09 12:26:06

下面是我在 init 方法末尾添加的一些代码,这些代码使我的小程序可调整大小。我的类扩展了JApplet

Window window = SwingUtilities.windowForComponent(this);
if (window instanceof JFrame) {
    JFrame frame = (JFrame) window;
    if (!frame.isResizable()) {
        frame.setResizable(true);
    }
}

希望这有帮助。

Here's a bit of code I added at the end of my init method that made my applet resizable. My class extends JApplet.

Window window = SwingUtilities.windowForComponent(this);
if (window instanceof JFrame) {
    JFrame frame = (JFrame) window;
    if (!frame.isResizable()) {
        frame.setResizable(true);
    }
}

Hope this helps.

爱要勇敢去追 2025-01-09 12:26:06

尽管已经是 2022 年了,我仍然遇到这个问题。

不,我不是开发团队的成员,也无法访问源代码。

我所做的是每次下载 JNLP 时都使用 shell 脚本将 JNLP 文件中的窗口大小更改为我喜欢的大小。

它不可调整大小,但我当然可以在 shell 脚本中更改窗口大小并重新启动 JNLP 应用程序。

TMPFILE=/tmp/app-resized.jnlp

cat ~/Downloads/app.jnlp | sed -e 's/width="1470" height="1250"/width="1024" height="768"/' > $TMPFILE
rm ~/Downloads/app.jnlp


javaws $TMPFILE 

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.

TMPFILE=/tmp/app-resized.jnlp

cat ~/Downloads/app.jnlp | sed -e 's/width="1470" height="1250"/width="1024" height="768"/' > $TMPFILE
rm ~/Downloads/app.jnlp


javaws $TMPFILE 
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文