Java Swing 排列 JInternalFrames

发布于 2024-08-25 15:18:44 字数 297 浏览 6 评论 0原文

Java Swing 中是否有用于排列 JInternalFrame 的默认功能?

我希望在我的 Java Swing 应用程序中具有 Cascade、Tile 等功能,如下所示: http://www.codeproject.com/KB/cs/mdiformstutorial.aspx 我只能找到他们手动安排的代码。 Java Swing 不支持这个还是我有点盲目?

Is there any default functionality for arranging JInternalFrames in Java Swing?

I would like to have the Cascade, Tile, etc... functionality within my Java Swing application like this: http://www.codeproject.com/KB/cs/mdiformstutorial.aspx
I could only find code where they did the arranging manually. Is there no support for this in Java Swing or am I a bit blind?

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

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

发布评论

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

评论(2

无声无音无过去 2024-09-01 15:18:44

我以前做过级联,但我是通过移动帧像素来创建效果的,我不知道另一种方法,我会计算出 JDesktopPane 有多大,然后使用 getAllFrames() 获取内部帧的数组,然后手动执行尺寸调整和移动。

我确信(尽管我已经至少两年没有寻找过)Swing 没有其他方法来执行这些操作,我确信某个地方有人编写了一个第三方库来连接到 Swing 应用程序,如果不是我会写一个并开源它:)

编辑,

只是想你可以做tile等的另一种方式,就是编写一个自定义布局管理器,为你完成繁重的工作,比如FrameTileLayoutManager,然后使用它..它只是一个想法。

I've done cascade before but I did it by shifting the frames pixels to create the affect I do not know another way of doing this, I would work out how big the JDesktopPane is then get an array of you internal frames with getAllFrames(), then perform the sizing and shifting manually.

I am certain (allthough I haven't looked for at least 2 years now) that swing has no other way to perform these operations, I'm sure someone somewhere has a written a third party library to bolt onto swing apps, if not I'd write one and open source it :)

Edit,

Just thought the other way you could do tile etc, would be to write a custom layout manager that did the heavy lifting work for you something like FrameTileLayoutManager, then use that.. its just a thought.

嗳卜坏 2024-09-01 15:18:44

这并不是真正的解决方案,而更像是一种 Hack。如果您可以在渲染框架之前读取桌面窗格的当前宽度,则可以级联/堆叠内部框架。

    int c=desktopPane.getAllFrames().length;
    Random r=new Random();
    if (c<3){
            RegistryDash registry = new RegistryDash();
            registry.setVisible(true);

            desktopPane.add(registry);
            //registry.setLocation(r.nextInt(200),r.nextInt(200));
            registry.setLocation(c*50,c*50);
            try {
                registry.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {
            }

    }else{
     JOptionPane.showMessageDialog(this,"More than three similar windows are currently active. Close some to allow new windows.","Multiple Window Error",JOptionPane.WARNING_MESSAGE);  
    }

This is not really a solution but more of a Hack. It is possible to cascade/ stack the internal frames if you can read the current width of the desktop pane before rendering the frame.

    int c=desktopPane.getAllFrames().length;
    Random r=new Random();
    if (c<3){
            RegistryDash registry = new RegistryDash();
            registry.setVisible(true);

            desktopPane.add(registry);
            //registry.setLocation(r.nextInt(200),r.nextInt(200));
            registry.setLocation(c*50,c*50);
            try {
                registry.setSelected(true);
            } catch (java.beans.PropertyVetoException e) {
            }

    }else{
     JOptionPane.showMessageDialog(this,"More than three similar windows are currently active. Close some to allow new windows.","Multiple Window Error",JOptionPane.WARNING_MESSAGE);  
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文