Results 1 to 20 of 21
Thread: NullPointerException Help!
- 04-29-2012, 05:22 AM #1
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
NullPointerException Help!
The program compiles fine and there are no errors or warnings. When I try to select the buyCheapTreat button I get a runtime NullPointerException error.
Java Code://When the button is clicked, the ActionListener implementation calls Owner.buyCheapTreat(). private class buyCheapTreatListener implements ActionListener{ public void actionPerformed(ActionEvent e){ theOwner.buyCheapTreat("Cheap Treat"); } }Java Code:/*buyCheapTreat(String) *If the Owner can afford the CheapTreat then Create a *cheap treat with the given description string and *adjust the credit count. */ public CheapTreat buyCheapTreat(String descrip){ CheapTreat aTreat = new CheapTreat(descrip); if(credits >= aTreat.getCost()){ adjustCredits(-aTreat.getCost()); addTreat(aTreat); return aTreat; } else{ return null; } }
- 04-29-2012, 05:27 AM #2
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
Sorry Line4 theOwner.buyCheapTreat("Cheap Treat"); is the one that is causing the runtime error. I'm not sure how to adjust the code to rectify this.
- 04-29-2012, 05:33 AM #3
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
Can you post the entire stack trace? What it prints out when it gives you the error. It sounds like it's trying to reference something that is not there.
- 04-29-2012, 05:36 AM #4
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at view.ICritterView$buyFancyTreatListener.actionPerf ormed(ICritterView.java:121)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.jav a:6375)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:614 0)
at java.awt.Container.processEvent(Container.java:208 3)
at java.awt.Component.dispatchEventImpl(Component.jav a:4737)
at java.awt.Container.dispatchEventImpl(Container.jav a:2141)
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4619)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4280)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4210)
at java.awt.Container.dispatchEventImpl(Container.jav a:2127)
at java.awt.Window.dispatchEventImpl(Window.java:2482 )
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:684)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:643)
at java.awt.EventQueue$1.run(EventQueue.java:641)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:657)
at java.awt.EventQueue$2.run(EventQueue.java:655)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 654)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
Line 121 in the code is line 4 referenced above.
- 04-29-2012, 05:44 AM #5
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
Ok, Can you post the rest of the code? I want to see where it is going wrong and run it for myself.
- 04-29-2012, 05:47 AM #6
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
I would probably need to email it to you, it is 10 classes all together.
Here's a dropbox link: https://www.dropbox.com/sh/f3swcq89823mc5o/NvdjSWrKXjLast edited by amazin112; 04-29-2012 at 05:54 AM.
- 04-29-2012, 06:14 AM #7
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
Since I can't get it to run. I can only offer you my best guess.
What is the value of credits when you are calling this. The fancy treats costs 5. If you can't afford it, it will return a null. This could be why you are getting your null reference.Java Code:public FancyTreat buyFancyTreat(String descrip){ FancyTreat aTreat = new FancyTreat(descrip); if(credits >= aTreat.getCost()){ adjustCredits(-aTreat.getCost()); addTreat(aTreat); return aTreat; } else{ return null; } }
- 04-29-2012, 06:23 AM #8
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
You couldn't compile the files I attached?
Here's the section of code where credits is defined and initialized:
Credits should be initialized as 30.Java Code:public class Owner extends Observable{ private ICritter iCritter; private List<Treat> treats; private Integer credits; private String name; /*The Owner constructor should create an iCritter * and initialize the credit count to 30 credits. */ public Owner(String ownerName, String critterName){ name = ownerName; iCritter = new ICritter(critterName, this); credits = 30; treats = new ArrayList<Treat>(); }
- 04-29-2012, 06:37 AM #9
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
I couldn't get the class ICritterController to run. It has the main method, so I figured it was the one I should call. I also couldn't compile some of the classes. I'll give it another shot. You made an instance of Owner, but you never initialized it.
That may be your null value.Java Code:Owner theOwner;
- 04-29-2012, 06:56 AM #10
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
That's exactly what the error was... Thank you for your help.
Here's how I changed the code to fix it:
Java Code:Owner theOwner = new Owner("", "");
- 04-29-2012, 07:03 AM #11
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
That works, although you may lose any information on it. You passed an Owner object to the constructor of ICritterView. All you have to do is assign it to the theOwner variable.
That way your not making a blank Owner object.Java Code:public ICritterView(Owner theOwner, ICritter theCritter){ this.theOwner = theOwner; setLayout(new BorderLayout()); }
This whole thing was a little above my coding abilities, but I worked through it the best I could.Last edited by Wnt2bsleepin; 04-29-2012 at 07:21 AM.
- 04-29-2012, 07:12 AM #12
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
You are right, making the blank Owner object doesn't only gets rid of the NPE it doesn't solve the problem. However when I try your solution of this.theOwner = theOwner; I am still getting the NPE error. Does this mean that something else is giving a null value?
- 04-29-2012, 07:23 AM #13
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
Re: NullPointerException Help!
- 04-29-2012, 07:48 AM #14
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
Here's the updated stack trace, I have also updated the dropbox file above in case the line numbers have changed since I have been messing with the code.
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at view.ICritterView.updateCredits(ICritterView.java: 232)
at view.ICritterView.updateOwnerComponents(ICritterVi ew.java:222)
at view.ICritterView.update(ICritterView.java:204)
at java.util.Observable.notifyObservers(Observable.ja va:142)
at model.Owner.adjustCredits(Owner.java:30)
at model.Owner.buyFancyTreat(Owner.java:74)
at view.ICritterView$buyFancyTreatListener.actionPerf ormed(ICritterView.java:126)
at javax.swing.AbstractButton.fireActionPerformed(Abs tractButton.java:2028)
at javax.swing.AbstractButton$Handler.actionPerformed (AbstractButton.java:2351)
at javax.swing.DefaultButtonModel.fireActionPerformed (DefaultButtonModel.java:387)
at javax.swing.DefaultButtonModel.setPressed(DefaultB uttonModel.java:242)
at javax.swing.plaf.basic.BasicButtonListener.mouseRe leased(BasicButtonListener.java:236)
at java.awt.Component.processMouseEvent(Component.jav a:6375)
at javax.swing.JComponent.processMouseEvent(JComponen t.java:3267)
at java.awt.Component.processEvent(Component.java:614 0)
at java.awt.Container.processEvent(Container.java:208 3)
at java.awt.Component.dispatchEventImpl(Component.jav a:4737)
at java.awt.Container.dispatchEventImpl(Container.jav a:2141)
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.LightweightDispatcher.retargetMouseEvent( Container.java:4619)
at java.awt.LightweightDispatcher.processMouseEvent(C ontainer.java:4280)
at java.awt.LightweightDispatcher.dispatchEvent(Conta iner.java:4210)
at java.awt.Container.dispatchEventImpl(Container.jav a:2127)
at java.awt.Window.dispatchEventImpl(Window.java:2482 )
at java.awt.Component.dispatchEvent(Component.java:45 65)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.j ava:684)
at java.awt.EventQueue.access$000(EventQueue.java:85)
at java.awt.EventQueue$1.run(EventQueue.java:643)
at java.awt.EventQueue$1.run(EventQueue.java:641)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:98)
at java.awt.EventQueue$2.run(EventQueue.java:657)
at java.awt.EventQueue$2.run(EventQueue.java:655)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.AccessControlContext$1.doIntersectio nPrivilege(AccessControlContext.java:87)
at java.awt.EventQueue.dispatchEvent(EventQueue.java: 654)
at java.awt.EventDispatchThread.pumpOneEventForFilter s(EventDispatchThread.java:296)
at java.awt.EventDispatchThread.pumpEventsForFilter(E ventDispatchThread.java:211)
at java.awt.EventDispatchThread.pumpEventsForHierarch y(EventDispatchThread.java:201)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:196)
at java.awt.EventDispatchThread.pumpEvents(EventDispa tchThread.java:188)
at java.awt.EventDispatchThread.run(EventDispatchThre ad.java:122)
- 04-29-2012, 06:27 PM #15
Senior Member
- Join Date
- Feb 2012
- Posts
- 219
- Rep Power
- 2
-
Re: NullPointerException Help!
You're not debugging your NPE correctly. Look at the *first line* in the stacktrace that references your class code:
That line, ICritterView.java, line 232, is the one with the null reference.Java Code:at view.ICritterView.updateCredits(ICritterView.java:232)
- 04-29-2012, 09:23 PM #17
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Re: NullPointerException Help!
I took that out and just added it to the method above it, seemed unnecessary. I'm going to just post the two classes in here to see if anyone has any ideas. I'm at a loss.
Here's the ICritterView.java
Here's the Owner.javaJava Code:package view; import java.awt.*; import java.awt.event.*; import java.util.*; import javax.swing.*; import model.*; public class ICritterView extends JPanel implements Observer{ private static final long serialVersionUID = 1L; Owner theOwner; ICritter theCritter; JList treatsList, memoriesList; JButton giveTreatButton, buyCheapTreatButton, buyFancyTreatButton; JLabel creditsLabel, numCreditsLabel; DefaultListModel treatsListModel, memoriesListModel; JPanel ownerPanel, critterPanel; JSlider happinessSlider; /*This method creates all of the Swing components needed and combines *them into the GUI. It should call updateiCritterComponents()and *updateOwnerComponents() to the appropriate components' values. */ public ICritterView(Owner theOwner, ICritter theCritter){ this.theOwner = theOwner; theOwner.addObserver(this); theOwner.getCritter().addObserver(this); setLayout(new BorderLayout()); /*The JPanel that contains the Owner-related components should have *a GridLayout layout manager with three rows and two columns. */ JPanel ownerPanel = new JPanel(); ownerPanel.setLayout(new GridLayout(3,2)); add(ownerPanel, BorderLayout.SOUTH); //The first JLabel should contain the String "Credits:" JLabel creditsLabel = new JLabel("Credits:"); ownerPanel.add(creditsLabel); //The second JLabel should contain a String with the number of credits the Owner has. JLabel numCreditsLabel = new JLabel(""+theOwner.getCredits()); ownerPanel.add(numCreditsLabel); /*The third entry should be a JList, and should list all of the treats *the Owner currently has (you can use a ListModel to deal with the *elements of the JList). */ treatsListModel = new DefaultListModel(); treatsList = new JList(treatsListModel); treatsList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); treatsList.setAutoscrolls(true); treatsList.setPreferredSize(new Dimension(150, 100)); setupTreatsList(theOwner.listTreats()); ownerPanel.add(treatsList); /*The fourth entry should be a JButton with the label "Give Treat". *This button should have an ActionListener implementation added to it. */ giveTreatButton = new JButton("Give Treat"); giveTreatButton.addActionListener(new giveTreatListener()); ownerPanel.add(giveTreatButton); /*The fifth entry should be a JButton with the label “Buy Fancy Treat.” *This button should have an ActionListener implementation added to it. */ buyFancyTreatButton = new JButton("Buy Fancy Treat"); buyFancyTreatButton.addActionListener(new buyFancyTreatListener()); ownerPanel.add(buyFancyTreatButton); /*Finally, the sixth entry should be a JButton with the label “Buy Cheap Treat.” *This button should have an ActionListener implementation added to it. */ buyCheapTreatButton = new JButton("Buy Cheap Treat"); buyCheapTreatButton.addActionListener(new buyCheapTreatListener()); ownerPanel.add(buyCheapTreatButton); //The JPanel containing the ICritter-related components should have a BorderLayout layout manager. JPanel critterPanel = new JPanel(); critterPanel.setLayout(new BorderLayout()); add(critterPanel, BorderLayout.EAST); //It should contain a JLabel at BorderLayout.NORTH containing the string “Happiness and Memories". JLabel handm = new JLabel("Happiness and Memories"); critterPanel.add(handm, BorderLayout.NORTH); /*It should also contain a JSlider at BorderLayout.CENTER, which has a scale from -4 to 4 and *starts out at the ICritter's happiness original happiness level. This JSlider represents *value returned by ICritter.getHappiness(). */ happinessSlider = new JSlider(); happinessSlider.setMinimum(-4); happinessSlider.setMaximum(4); happinessSlider.setValue((int) theCritter.getHappiness()); critterPanel.add(happinessSlider, BorderLayout.CENTER); /*Finally, this JPanel should contain a JList at BorderLayout.SOUTH, which lists the last *eight ICritterMemoryEvents in the ICritter. */ memoriesListModel = new DefaultListModel(); memoriesList = new JList(memoriesListModel); memoriesList.setPreferredSize(new Dimension(150, 200)); setupMemoriesList(theCritter.getMemories()); critterPanel.add(memoriesList, BorderLayout.SOUTH); //A JPanel with an ImageIcon containing the ICritter's image ImageIcon picture = new ImageIcon("images/iCritter.jpg"); JLabel pictureLabel = new JLabel("", picture, JLabel.CENTER); add(pictureLabel, BorderLayout.CENTER); //A JLabel with your name and the iCritter's name JLabel names = new JLabel("iCritter: "+theOwner.getCritter().getName()+" Owner: "+theOwner.getName()); add(names, BorderLayout.NORTH); } //When the button is clicked, the ActionListener implementation calls Owner.buyFancyTreat(). private class buyFancyTreatListener implements ActionListener{ public void actionPerformed(ActionEvent e){ theOwner.buyFancyTreat("Fancy Treat"); } } //When the button is clicked, the ActionListener implementation calls Owner.buyCheapTreat(). private class buyCheapTreatListener implements ActionListener{ public void actionPerformed(ActionEvent e){ theOwner.buyCheapTreat("Cheap Treat"); } } /*When the button is clicked, the ActionListener implementation should see which *treat is highlighted in the JList, remove that treat entry from the JList, and *call Owner.giveTreat() on the corresponding treat in the Owner's treat list. */ private class giveTreatListener implements ActionListener{ public void actionPerformed(ActionEvent arg0) { int index = treatsList.getSelectedIndex(); if(index == -1){ JOptionPane.showMessageDialog(null,new JLabel("Select a treat to be given.")); } else{ Treat treatToGive = theOwner.listTreats().get(index); theOwner.giveTreat(treatToGive); } } } /*The list should have an entry called “Fancy Treat” for each FancyTreat instance in *the Owner's treat list, and it should have an entry called “Cheap Treat” for each *CheapTreat instance in the Owner's treat list. */ private void setupTreatsList(java.util.List<Treat> theTreats){ treatsListModel.clear(); for(Treat i : theTreats){ if(i instanceof CheapTreat) treatsListModel.addElement("Cheap Treat"); else if(i instanceof FancyTreat) treatsListModel.addElement("Fancy Treat"); } this.validate(); } /*Each entry should indicate the treat type (“Fancy Treat” or “Cheap Treat”) and the corresponding *ICritterReaction.getMoodModifier() value (which should still be a positive integer). This list *should be sorted from top-to-bottom where the most recent memory is at the bottom. */ private void setupMemoriesList(java.util.List<ICritterMemoryEvent> memories){ int i; if(memories.size() < 8) i = 0; else i = memories.size() - 8; java.util.List<ICritterMemoryEvent> lastEightMemories = memories.subList(i, memories.size()); memoriesListModel.clear(); for(ICritterMemoryEvent j : lastEightMemories){ String lineOutput = ""; if(j.getRememberedTreat() instanceof CheapTreat) lineOutput += "Cheap Treat"; else if(j.getRememberedTreat() instanceof FancyTreat) lineOutput += "Fancy Treat"; lineOutput += " (Reaction to "+j.getRememberedTreat()+" was: "+j.getRememberedReaction().getMoodModifier()+")"; memoriesListModel.addElement(lineOutput); } } @Override public void update(Observable arg0, Object arg1){ ICritterUpdate update = (ICritterUpdate)arg1; if(update.getUpdateType() == ICritterUpdate.UPDATE_ICRITTER) updateICritterComponents((ICritter)arg0); else if(update.getUpdateType() == ICritterUpdate.UPDATE_OWNER) updateOwnerComponents((Owner)arg0); } /*This method updates all of the iCritter-related components in the GUI to *reflect the data within the given iCritter instance. It should be called *from the update() method inherited from Observer, and even then it should *only be called if the Object passed to update() is an instance of ICritterUpdate, *and that instance's updateType member is equal to ICritterUpdate.UPDATE_iCRITTER. */ public void updateICritterComponents(ICritter theCritter){ happinessSlider.setValue((int)theCritter.getHappiness()); setupMemoriesList(theCritter.getMemories()); } public void updateOwnerComponents(Owner theOwner){ setupTreatsList(theOwner.listTreats()); numCreditsLabel.setText(""+theOwner.getCredits()); } }
And here's the updated stack trace:Java Code:package model; import java.util.*; import view.ICritterUpdate; public class Owner extends Observable{ private ICritter iCritter; private List<Treat> treats; private int credits; private String name; /*The Owner constructor should create an iCritter * and initialize the credit count to 30 credits. */ public Owner(String ownerName, String critterName){ name = ownerName; iCritter = new ICritter(critterName, this); credits = 30; treats = new LinkedList<Treat>(); } /*adjustCredits(Integer) *Adds the given Integer to the Owners's number of credits. */ private void adjustCredits(int amount){ credits += amount; setChanged(); notifyObservers(new ICritterUpdate(ICritterUpdate.UPDATE_OWNER)); } /*addTreat(Treat) *Add a Treat to the Owner's list of treats. */ public void addTreat(Treat aTreat){ treats.add(aTreat); setChanged(); notifyObservers(new ICritterUpdate(ICritterUpdate.UPDATE_OWNER)); } /*listTreats() *Return a list of the Ownder's treats *(this could be an empty list). */ public List<Treat> listTreats(){ return treats; } /*buyCheapTreat(String) *If the Owner can afford the CheapTreat then Create a *cheap treat with the given description string and *adjust the credit count. */ public CheapTreat buyCheapTreat(String descrip){ CheapTreat aTreat = new CheapTreat(descrip); if(credits >= aTreat.getCost()){ adjustCredits(-aTreat.getCost()); addTreat(aTreat); return aTreat; } else{ return null; } } public FancyTreat buyFancyTreat(String descrip){ FancyTreat aTreat = new FancyTreat(descrip); if(credits >= aTreat.getCost()){ adjustCredits(-aTreat.getCost()); addTreat(aTreat); return aTreat; } else{ return null; } } /*giveTreat(Treat) *If the Owner owns the treat, then give the treat *to the Critter and remove the Treat from the list treats. */ public ICritterReaction giveTreat(Treat aTreat){ if(treats.contains(aTreat)){ treats.remove(aTreat); setChanged(); notifyObservers(new ICritterUpdate(ICritterUpdate.UPDATE_OWNER)); return iCritter.receiveTreat(aTreat); } else return null; } //getCritter() public ICritter getCritter(){ return iCritter; } //getName() public String getName(){ return name; } //getCredits public Integer getCredits(){ return credits; } }
Line 222 in ICritterView is:Java Code:Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException at view.ICritterView.updateOwnerComponents(ICritterView.java:222) at view.ICritterView.update(ICritterView.java:204) at java.util.Observable.notifyObservers(Observable.java:142) at model.Owner.adjustCredits(Owner.java:30) at model.Owner.buyCheapTreat(Owner.java:61) at view.ICritterView$buyCheapTreatListener.actionPerformed(ICritterView.java:134) at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2028) at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2351) 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:6375) at javax.swing.JComponent.processMouseEvent(JComponent.java:3267) at java.awt.Component.processEvent(Component.java:6140) at java.awt.Container.processEvent(Container.java:2083) at java.awt.Component.dispatchEventImpl(Component.java:4737) at java.awt.Container.dispatchEventImpl(Container.java:2141) at java.awt.Component.dispatchEvent(Component.java:4565) at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4619) at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4280) at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4210) at java.awt.Container.dispatchEventImpl(Container.java:2127) at java.awt.Window.dispatchEventImpl(Window.java:2482) at java.awt.Component.dispatchEvent(Component.java:4565) at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:684) at java.awt.EventQueue.access$000(EventQueue.java:85) at java.awt.EventQueue$1.run(EventQueue.java:643) at java.awt.EventQueue$1.run(EventQueue.java:641) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:98) at java.awt.EventQueue$2.run(EventQueue.java:657) at java.awt.EventQueue$2.run(EventQueue.java:655) at java.security.AccessController.doPrivileged(Native Method) at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:87) at java.awt.EventQueue.dispatchEvent(EventQueue.java:654) at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:296) at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:211) at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:201) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:196) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:188) at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
I know where the problem is, I just don't know how to fix it. Any suggestions?Java Code:numCreditsLabel.setText(""+theOwner.getCredits());
-
Re: NullPointerException Help!
-
Re: NullPointerException Help!
Last edited by Fubarable; 04-30-2012 at 02:38 AM.
- 04-30-2012, 03:24 AM #20
Member
- Join Date
- Apr 2012
- Posts
- 10
- Rep Power
- 0
Similar Threads
-
NullPointerException
By jayragz in forum NetBeansReplies: 5Last Post: 05-12-2011, 05:19 PM -
Nullpointerexception?
By Pulgo in forum New To JavaReplies: 5Last Post: 01-05-2011, 04:05 PM -
NullPointerException
By s0meb0dy in forum New To JavaReplies: 3Last Post: 10-09-2010, 08:12 PM -
NullPointerException I NEED HELP
By mayhewj7 in forum New To JavaReplies: 2Last Post: 02-13-2009, 08:03 AM -
I get a NullPointerException and don't know why
By hendrix79 in forum New To JavaReplies: 9Last Post: 12-14-2008, 06:18 AM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks