permaculture playing cards*
The moose likes Swing / AWT / SWT and the fly likes Error while trying to create a JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Error while trying to create a JTable" Watch "Error while trying to create a JTable" New topic
Author

Error while trying to create a JTable

Krithika Beri
Ranch Hand

Joined: Sep 11, 2012
Posts: 36
I am taking elements from a Dom parser and writing its content into a JTable with TreeSelectionListener() of JTree to indicate which node's data is to be displayed.

Krithika Beri
Ranch Hand

Joined: Sep 11, 2012
Posts: 36
I am getting the following error..

HomeWork1 (class=assessment-practice-tests, container_type=homework, displayName=HomeWork1, id=HomeWork1, playOrder=1)
Node name :class
Node Value :assessment-practice-tests
j :0
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Main.tables(Main.java:166)
at Main$2.valueChanged(Main.java:130)
at javax.swing.JTree.fireValueChanged(Unknown Source)
at javax.swing.JTree$TreeSelectionRedirector.valueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.notifyPathChange(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPaths(Unknown Source)
at javax.swing.tree.DefaultTreeSelectionModel.setSelectionPath(Unknown Source)
at javax.swing.JTree.setSelectionPath(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI.selectPathForEvent(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.handleSelection(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressedDND(Unknown Source)
at javax.swing.plaf.basic.BasicTreeUI$Handler.mousePressed(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at javax.swing.JComponent.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Container.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
at java.awt.Container.dispatchEventImpl(Unknown Source)
at java.awt.Window.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Darryl Burke
Bartender

Joined: May 03, 2008
Posts: 4642
    
    5

Krithika Beri wrote:I am getting the following error..
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Main.tables(Main.java:166

Which is line 166? What variable(s) is (are) dereferenced on that line?


luck, db
There are no new questions, but there may be new answers.
Krithika Beri
Ranch Hand

Joined: Sep 11, 2012
Posts: 36

is line 166
Krithika Beri
Ranch Hand

Joined: Sep 11, 2012
Posts: 36
Is there a problem with the Object declaration?
Krithika Beri
Ranch Hand

Joined: Sep 11, 2012
Posts: 36
The problem was with object declaration.
I made the following changes for it to work.

 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Error while trying to create a JTable