Java - 同一窗口上的另一个 JFrame

发布于 2025-01-02 18:32:28 字数 222 浏览 4 评论 0原文

我想要的是创建一个新的 JFrame,保持当前的 JFrame 可见,但不创建新的窗口/程序。我无法很好地解释它,所以这是我的意思的图片:

http://screensnapr.com /e/mkCMlm.png

抱歉,如果这有任何令人困惑的地方。任何帮助表示赞赏。

What I want is to make a new JFrame, keeping my current JFrame visible, but not create a new window/program. I can't explain it well, so here is a picture of what I mean:

http://screensnapr.com/e/mkCMlm.png

Sorry if this is confusing in any way. Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

漫漫岁月 2025-01-09 18:32:28

您可以尝试 http://docs.oracle.com/javase/tutorial/ uiswing/components/internalframe.html

另外,您可以尝试在新窗口中使用对话框而不是框架。

You can try http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html

Also you can try to use a dialog rather than frame for the new window.

雨落□心尘 2025-01-09 18:32:28

如果我理解正确的话,您需要 JInternalFrame,它是 swing 中的一个特殊组件,位于名为 Desktop 的容器内。因此,如果您想要有这样的行为:

在此处输入图像描述

您肯定需要在 JFrame 中有一个名为JDesktopPane,那么你可以在这个容器中添加JInternalFrame,如下所示:

 MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame);
    try {
        frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {ex.printStackTrace();}

有关更多信息,您可以查看官方oracle文档Java2SE 代码示例

If I understood correctly you want JInternalFrame which are a special component in swing that live inside a Container named Desktop. So if you want to have a behaviour like this:

enter image description here

You definitely need to have inside your JFrame a container named JDesktopPane, then you can add JInternalFrame inside this container like this:

 MyInternalFrame frame = new MyInternalFrame();
    frame.setVisible(true);
    desktop.add(frame);
    try {
        frame.setSelected(true);
    } catch (java.beans.PropertyVetoException e) {ex.printStackTrace();}

For more information you can see official oracle documentation or Java2SE code samples

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