在 JSplitPane Java 中显示 JFrame

发布于 2025-01-07 19:12:48 字数 1421 浏览 6 评论 0原文

我正在使用 JSplitPane 制作 GUI,我想在 JSplitPane 的左侧显示一个 JFrame 和另一个 JFrame 在 JSplitPane 的右侧。 另一个 JFrame 的名称是 Minimize.javaDiagram.java。我的问题是如何调用它们并将其显示在 JSplitPane 的左侧和右侧?这篇文章的更新,我将 JFrame 转换为 JPanel 并成功显示,但现在的问题是它没有执行该功能/方法。

这是我的主窗体代码。

        public LogicGates()
        {
            Minimize mi = new Minimize();

             //mi.setVisible(true);
            JLabel iExp = new JLabel("Inputted Expression: ");
            p.add(iExp);
            j1= new JLabel("");
            j1.setVisible(false);
            p.add(j1);


            JScrollPane aaScrollPane = new JScrollPane(aa);

//here is my problem,when i run the code it displays the label and jcombobox but didn't perform the function
            gatessplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mi, aaScrollPane);
            gatessplit.setOneTouchExpandable(true);
            gatessplit.setDividerLocation(300);

            //Provide minimum sizes for the two components in the split pane.
            Dimension minimumSize = new Dimension(150, 80);
            //frame.setMinimumSize(minimumSize);
            aaScrollPane.setMinimumSize(minimumSize);

            //Provide a preferred size for the split pane.
            gatessplit.setPreferredSize(new Dimension(900, 500));


        }

I'm making GUI using JSplitPane and I want to display a JFrame in the left side of the JSplitPane and another JFrame inside the right side of a JSplitPane.
The name of the other JFrame is Minimize.java and Diagram.java. My problem is how can i call these and display it in the left and right side of the JSplitPane? An update for this post, I converted my JFrame to a JPanel and successful displayed but the problem now is it didn't perform the function/method.

Here's my code for the Main Form.

        public LogicGates()
        {
            Minimize mi = new Minimize();

             //mi.setVisible(true);
            JLabel iExp = new JLabel("Inputted Expression: ");
            p.add(iExp);
            j1= new JLabel("");
            j1.setVisible(false);
            p.add(j1);


            JScrollPane aaScrollPane = new JScrollPane(aa);

//here is my problem,when i run the code it displays the label and jcombobox but didn't perform the function
            gatessplit = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mi, aaScrollPane);
            gatessplit.setOneTouchExpandable(true);
            gatessplit.setDividerLocation(300);

            //Provide minimum sizes for the two components in the split pane.
            Dimension minimumSize = new Dimension(150, 80);
            //frame.setMinimumSize(minimumSize);
            aaScrollPane.setMinimumSize(minimumSize);

            //Provide a preferred size for the split pane.
            gatessplit.setPreferredSize(new Dimension(900, 500));


        }

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

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

发布评论

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

评论(1

初熏 2025-01-14 19:12:48

您不能在此处将 JPanelsJFrame 上的 Layout Manager 结合使用吗?

这将允许您创建一个 JFrame,然后向其中添加一个由左侧和右侧两个部分组成的布局。然后,您可以在左侧和右侧添加一个 JPanel,并向每个 JPanel 添加组件。

JPanel 教程http://docs.oracle .com/javase/tutorial/uiswing/components/panel.html

布局教程http://docs.oracle.com/javase/tutorial/uiswing/layout/visual .html

Could you not use JPanels here combined with a Layout Manager on the JFrame?

This will allow you to create a JFrame, then add a layout to it comprising of two sections on the left and right. You can then add a JPanel to the left and right and add components to each JPanel.

JPanel tutorial: http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html

Layout tutorial: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html

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