我创建了一个JDialog
。当它出现时,我有一个JTabbedPane
,上面有几个FormPanel
个。表单面板作为表单文件加载(我使用Abeille来创建表单。)在尝试将JTable
添加到其中一个表单之前,我没有遇到任何问题(同样,通过Abeille 。)我像其他选项卡一样添加表单,但是当我运行dialog.pack
时,它会抛出NullPointerException
。该表单中的表格似乎不是null
,因为我可以从中获取值。我看不出导致null
的原因。
private JDialog m_dialog;
private FormPanel m_panelForm;
private FormPanel m_tableEditorForm;
private FormPanel m_fieldEditorForm;
private FormPanel m_seedDataEditorForm;
JFrame appFrame = App.getInstance().getFrame();
m_dialog = new JDialog(appFrame, "Dialog Title"), true);
m_dialog.setName("Dialog"));
m_dialog.setLocationRelativeTo(appFrame);
// Load dialog layout
m_panelForm = getFormPanel("DLG_EDIT_PANEL");
m_tableEditorForm = getFormPanel("DLG_TABLE_EDITOR");
m_fieldEditorForm = getFormPanel("DLG_FIELD_EDITOR");
m_seedDataEditorForm = getFormPanel("DLG_SEED_DATA_EDITOR");
JTabbedPane pane = m_panelForm.getTabbedPane("editPane");
//Set up the tabs
pane.insertTab("Table", null, m_tableEditorForm, null, 0);
pane.insertTab("Field", null, m_fieldEditorForm, null, 1);
pane.insertTab("Seed", null, m_seedDataEditorForm, null, 2);
m_panelForm.reset();
m_dialog.setContentPane(m_panelForm);
m_dialog.pack();
第三个插入物,称为“种子”的插入物是将其吹出的插入物;如果我注释掉该行,其他标签显示正常。同样,如果我从Abeille中的表单中删除JTable
,则标签显示正常。
请注意,columnCount
和rowCount
默认为2.另请注意,如果我关闭打包,我会setVisible
关闭JDialog
,会引发相同的错误
任何帮助将不胜感激;我对Swing很好,但远没有好。
堆栈跟踪:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at com.jeta.open.support.DefaultComponentFinder.unregisterComponent(Unknown Source) at com.jeta.open.support.DefaultComponentFinder.componentRemoved(Unknown Source) at java.awt.AWTEventMulticaster.componentRemoved(AWTEventMulticaster.java:193) at java.awt.Container.processContainerEvent(Container.java:2070) at java.awt.Container.processEvent(Container.java:2038) at java.awt.Component.dispatchEventImpl(Component.java:4652) at java.awt.Container.dispatchEventImpl(Container.java:2099) at java.awt.Component.dispatchEvent(Component.java:4482) at java.awt.Container.remove(Container.java:1162) at java.awt.Container.remove(Container.java:1198) at java.awt.Container.addImpl(Container.java:1046) at java.awt.Container.add(Container.java:927) at javax.swing.plaf.basic.BasicScrollPaneUI.updateColumnHeader(BasicScrollPaneUI.java:606) at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.scrollPanePropertyChange(BasicScrollPaneUI.java:1102) at javax.swing.plaf.basic.BasicScrollPaneUI$Handler.propertyChange(BasicScrollPaneUI.java:1079) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:339) at java.beans.PropertyChangeSupport.firePropertyChange(PropertyChangeSupport.java:276) at java.awt.Component.firePropertyChange(Component.java:8154) at javax.swing.JScrollPane.setColumnHeader(JScrollPane.java:1095) at javax.swing.JScrollPane.setColumnHeaderView(JScrollPane.java:1120) at javax.swing.JTable.configureEnclosingScrollPane(JTable.java:713) at javax.swing.JTable.addNotify(JTable.java:684) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at java.awt.Container.addNotify(Container.java:2578) at javax.swing.JComponent.addNotify(JComponent.java:4685) at javax.swing.JRootPane.addNotify(JRootPane.java:739) at java.awt.Container.addNotify(Container.java:2578) at java.awt.Window.addNotify(Window.java:663) at java.awt.Dialog.addNotify(Dialog.java:743) at java.awt.Window.pack(Window.java:704) at com.follett.fsc.core.utils.schema.workbench.gui.dialogs.EditTableDialog.showDialog(EditTableDialog.java:108) at com.follett.fsc.core.utils.schema.workbench.gui.components.Tab.doEditTableRow(Tab.java:1354) at com.follett.fsc.core.utils.schema.workbench.gui.components.Tab.doEditRow(Tab.java:1437) at com.follett.fsc.core.utils.schema.workbench.gui.components.Tab$17$1.run(Tab.java:1016) at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:642) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:603) at java.awt.EventQueue$1.run(EventQueue.java:601) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:612) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)