getParent.add(组分)

时间:2012-03-26 10:50:01

标签: swing jtable jframe jinternalframe

我正在尝试从数据库中获取记录的特定值我使用AbstractTableModel在swings中创建运行时JTable但是我试图从该类的不同javaclass中触发查询。我为where子句提供条件但是我无法在其他JFrame中显示该记录.AbstractTableModel工作正常,因为我能够在我实际声明表的内部框架中检索数据..我可以将JInternalFrame中的数据转换为JFrame我试图使用getParent.add( )方法但它会抛出nullpointerException Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at secondproject.select_particular_field$1.actionPerformed(select_particular_field.java:84) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318) at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387) at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242) at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:236) at java.awt.Component.processMouseEvent(Component.java:6038) at javax.swing.JComponent.processMouseEvent(JComponent.java:3260) at java.awt.Component.processEvent(Component.java:5803) at java.awt.Container.processEvent(Container.java:2058) at java.awt.Component.dispatchEventImpl(Component.java:4410) at java.awt.Container.dispatchEventImpl(Container.java:2116) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4322) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3986) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3916) at java.awt.Container.dispatchEventImpl(Container.java:2102) at java.awt.Window.dispatchEventImpl(Window.java:2429) at java.awt.Component.dispatchEvent(Component.java:4240) at java.awt.EventQueue.dispatchEvent(EventQueue.java:599) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:273) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:183) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:173) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160) at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

1 个答案:

答案 0 :(得分:0)

它有点模糊,但通常会抛出NPE,因为在对象不存在时调用方法。在这种情况下,当您点击按钮select_particular_field.java

时,似乎会发生这种情况
  

但是我试图从该类

中的不同javaclass触发查询

也许这就是问题所在。在不同的类中,对象不存在/尚未创建。

希望它有所帮助