Java JSplitPane未喷漆
在我的应用程序中,我有一个Java JSplitPane未喷漆,java,swing,jsplitpane,Java,Swing,Jsplitpane,在我的应用程序中,我有一个JFrame显示一个JSplitPane,拆分为VERTICAL\u split。顶部显示一个JLabel,底部显示一个JInternalFrame。出现了两个问题 JLabel正在显示,但JInternalFrame不显示 二,。我必须调整应用程序的大小,才能显示JSplitPane 我认为这与不正确使用JSplitPane有关。然而,我一直无法弄清楚是什么。我可以在这个问题上得到一些帮助吗 p、 我已经运行了测试以确保GUIWindow.getInsideFram
JFrame
显示一个JSplitPane
,拆分为VERTICAL\u split
。顶部显示一个JLabel
,底部显示一个JInternalFrame
。出现了两个问题
JLabel
正在显示,但JInternalFrame
不显示
二,。我必须调整应用程序的大小,才能显示JSplitPane
JSplitPane
有关。然而,我一直无法弄清楚是什么。我可以在这个问题上得到一些帮助吗
p、 我已经运行了测试以确保GUIWindow.getInsideFrame()
没有返回null
。最后的instanceof
检查表明窗格中的两个组件都存在并且属于该类型。非常感谢您的帮助:
protected static void newWindow(GUIFrame window) {
SwingUtilities.invokeLater(new Runnable(){
@Override
public void run() {
JSplitPane pane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
JInternalFrame intFrame = window.getInsideFrame();
pane.setRightComponent(intFrame);
pane.setLeftComponent(new JLabel(window.getDescription()));
synchronized(lock){
frame.remove(currentPane);
frame.add(pane);
}
synchronized(lock){
frame.revalidate();
pane.setVisible(true);
frame.repaint();
if(window instanceof ColourFrameShower) return;
currentWindow = window;
currentPane = pane;
currentFrame = intFrame;
}
if(pane.getLeftComponent() instanceof JLabel) System.out.println("JLabel exists!");
else System.out.println("JLabel does not exist!");
if(pane.getRightComponent() instanceof JInternalFrame) System.out.println("JInternalFrame exists!");
else System.out.println("JInternalFrame does not exist!");
}
});
}
编辑:我修复了第二个
同步(锁定)
块开始时调用frame.revalidate()
的问题2。这已包含在代码中。尝试设置resizeWeight:pane.setResizeWeight(0.5) 正如我在评论中告诉您的,您只需在JInternalFrame
上使用setVisible(true)
,否则您的JSplitPane将不会考虑它
这是java swing上非常常见的错误
我很高兴它帮助了你;) 这对我没有任何帮助,但感谢您的快速响应!:)感谢您的编辑:)您是否尝试单独显示JInternalFrame,而不显示JSplitPanel?工作正常吗?:)是的,没有JSplitPanel它就可以工作了。在我的github上查看整个应用程序的最新版本:我做了一些测试,试图重现您的问题。我的标签和JInternalFrame显示正确。您的JInternalFrame是否设置为设置可见(true)
?谢谢您,先生!如果你把它作为一个答案,我会接受的。