在 JSplitPane Java 中显示 JFrame
我正在使用 JSplitPane
制作 GUI,我想在 JSplitPane
的左侧显示一个 JFrame
和另一个 JFrame 在
JSplitPane
的右侧。 另一个 JFrame
的名称是 Minimize.java
和 Diagram.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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不能在此处将
JPanels
与JFrame
上的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 aLayout Manager
on theJFrame
?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 aJPanel
to the left and right and add components to eachJPanel
.JPanel tutorial: http://docs.oracle.com/javase/tutorial/uiswing/components/panel.html
Layout tutorial: http://docs.oracle.com/javase/tutorial/uiswing/layout/visual.html