我有以下代码:
JTabbedPane container;
...
AWindow page = WinUtils.buildWindow();
boolean existing = checkIfExists(page); // in this code, this will always be false
if(!existing)
{
String tabName = page.getLoadedFileLocation().getName();
container.addTab(page.getLoadedFileLocation().getName(), page);
}
Component comp = container.getTabComponentAt(0);
int sel = container.getSelectedIndex();
container.setSelectedComponent(page);
事情是 :
container.getTabComponentAt(0)
返回null
。另一个奇怪的事情是:
container.getSelectedIndex()
返回0
。我认为应该发生的合乎逻辑的事情是引用创建的窗口。为什么我会收到null
?我究竟做错了什么?