在我的應用程序中,我有一個JFrame
顯示JSplitPane
,分割爲VERTICAL_SPLIT
。頂部顯示一個JLabel
,底部顯示一個JInternalFrame
。發生兩個問題。JSplitPane沒有繪畫修正
的
JLabel
被顯示,但JInternalFrame
不是。2.我在所有
我相信這是首尾相連的不正確使用的JSplitPane
來調整應用程序有JSplitPane
顯示。但是,我一直無法解決什麼問題。我可以幫助解決這個問題嗎?
p.s.我已經運行測試以確保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!");
}
});
}
編輯:我固定的問題2在第二synchronised(lock)
塊的開始frame.revalidate()
通話。這已包含在代碼中。
謝謝 – JD9999
你試圖顯示只有你的JInternalFrame編輯:),沒有JSplitPanel?它工作嗎? :) – Kapcash
是的,沒有JSplitPanel它正在工作。在我的github上查看整個應用程序的最新版本:https://github.com/JD9999/GUI-of-everything – JD9999