Home arrow static arrow Java Programming [Archive] - unrecgnized ActionEvent
Warning: Creating default object from empty value in /www/htdocs/w008deb8/wiki/components/com_staticxt/staticxt.php on line 51
Java Programming [Archive] - unrecgnized ActionEvent
This topic has 4 replies on 1 page.

Posts:2
Registered: 8/4/04
unrecgnized ActionEvent  
Aug 4, 2004 6:48 AM



 
I have been programming in ANSI/ISO C++ for a while, and just started to learn Java so that I could write a GUI to a set of tools that currently only has a command line interface. I got the GUI designed OK, and am now adding ActionListeners and such to it. I have an action listener on the Save MenuItem under the File menu, and a corresponding actionPerformed listener. I have tried both checking for getActionCommand() to match the save MenuItem title and checking for the object to be mnuSave. In either case, I get the following in the tcsh in the background wiki/./when I run the class and click on the Save item:

java.lang.NullPointerException
at CombustView.actionPerformed(CombustView.java:347)
at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
at javax.swing.AbstractButton.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI.doClick(Unknown Source)
at javax.swing.plaf.basic.BasicMenuItemUI$MouseInputHandler.mouseReleased(Unknown Source)
at java.awt.Component.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.pumpOneEventForHierarchy(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)

I have tried this w/ an ActionListener for both the File menu and the Save item and just for the Save item. actionPerformed is delcared as public void. What's going wrong? I have checked three sources that all do this and they all work, so why doesn't my code work?
 

Posts:19,725
Registered: 9/26/01
Re: unrecgnized ActionEvent  
Aug 4, 2004 6:51 AM (reply 1 of 4)



 
java.lang.NullPointerException
at CombustView.actionPerformed(CombustView.java:347)
Can't you bother to look at your own source code, line 347, and take it from there?
 

Posts:2
Registered: 8/4/04
Re: unrecgnized ActionEvent  
Aug 4, 2004 7:56 AM (reply 2 of 4)



 
The first thing I did was go over my code. I went over it again after posting and found that I forgot to instatiate an object I was using a member method of in the actionPerformed(). Having to instatiate objects is sone at different times for different things in C++. Some of us aren't as experinced as you are. Remember that in the future. I found your response a bit rude., but thanks for the help anyway. I don't think I'll be using this forum anymore.
 

Posts:24,517
Registered: 98-02-27
Re: unrecgnized ActionEvent  
Aug 4, 2004 9:24 PM (reply 3 of 4)



 
I don't think I'll be using this forum anymore.

You got an answer within 3 minutes.

The answer stated the obvious -. Look at the line causing the error.

I think you'll miss the forum more than we miss you.
 

Posts:2,909
Registered: 13.8.2003
Re: unrecgnized ActionEvent  
Aug 4, 2004 11:15 PM (reply 4 of 4)



 
People seem to think we're getting paid for this.

In our world, the customer is always wrong!!!
 
This topic has 4 replies on 1 page.