Results 1 to 5 of 5
- 05-14-2010, 09:30 PM #1
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
Extracting Keys from Hashtable fails
Hello!
To cut a long story short:
I'm trying to iterate through an hashtable and therefore i want to extract the keys of it.
But both...
Set<String> set = hashtable.keySet();
and
Enumeration e = hashtable.keys();
fail in a very strange way. My program doesn't crash oder something like that (started in eclipse btw.), I just get the following errormessage on the console.
Maybe it has something to do with Swing? I cannot reproduce the error in a console app, but I only tried it once, so don't pay too much attention on this hint.
The error:
By the way, "at Feed.addItems(Feed.java:32)", this is the position of keys()/keyset() in my code.Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at Feed.addItems(Feed.java:32)
at Gui.update(Gui.java:204)
at Gui.access$0(Gui.java:170)
at Gui$2.actionPerformed(Gui.java:53)
at javax.swing.AbstractButton.fireActionPerformed(Unk nown Source)
at javax.swing.AbstractButton$Handler.actionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed (Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(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(U nknown Source)
at java.awt.LightweightDispatcher.dispatchEvent(Unkno wn 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.pumpOneEventForFilter s(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(U nknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)
Thank you!Last edited by Okay123; 05-14-2010 at 09:35 PM.
- 05-14-2010, 09:35 PM #2
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,602
- Blog Entries
- 7
- Rep Power
- 17
Look carefully at line #32 of your Feed class; there's an object there that is null while it shouldn't be and your code is dereferencing it.
kind regards,
Jos
- 05-14-2010, 09:43 PM #3
Member
- Join Date
- May 2010
- Posts
- 2
- Rep Power
- 0
I lost sight of the forest for the trees, thank you!
- 05-17-2010, 08:12 PM #4
this one is hard to debug just from your code and stack trace. try extracting your code out to a small program, run it again and see if that fails. best guess is that its not a problem with iterating through the ketset but a concurrent problem thats masking the issue
- 05-18-2010, 09:27 AM #5
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
connection fails
By jrjan in forum Advanced JavaReplies: 3Last Post: 01-10-2009, 12:15 AM -
Over-riding purpose fails..
By udayadas in forum New To JavaReplies: 7Last Post: 08-24-2008, 04:14 AM -
Uisng primitive type values as keys for Hashtable
By ravian in forum New To JavaReplies: 3Last Post: 11-21-2007, 10:13 AM -
Repaint fails when using threads
By rjevans2000 in forum Threads and SynchronizationReplies: 1Last Post: 09-21-2007, 11:22 PM -
Repaint fails when using threads
By rjevans2000 in forum AWT / SwingReplies: 3Last Post: 08-15-2007, 05:42 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks