Adding a JTable to my Pane Inside a Dialog Throws an NPE when I pack it
I have created a JDialog
. When it comes up, I have a JTabbedPane
that has several FormPanel
s on it. The form panels are loaded in as a form file (I used Abeille to create the forms.) I have had no problems until I tried to add a JTable
to one of the forms (again, through Abeille.) I add the form like I did the rest of the tabs, but when I run dialog.pack
, it throws a NullPointerException
. The table inside that form does not appear to be null
as I can get values from it. I cannot see what is causing the 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(开发者_C百科"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();
The third insert, the one called "Seed" is the one that blows it out; if I comment out the line the other tabs show up fine. Similarly, if I remove the JTable
from the form in Abeille the tab shows up fine.
Note the columnCount
and rowCount
defaults to 2. Also note that if I turn off pack, I have a setVisible
off of the JDialog
that throws the same error.
Any help would be appreciated; I'm okay at Swing but far from good.
Stacktrace:
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)
精彩评论