NullPointerException but can't find error

Error I am receiving

java.lang.NullPointerException

at buttons.PlayPause.getState(PlayPause.java:36)

at net.KrayaProcessDash.Events.actionPerformed(Events.java:29)

at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1786)

at javax.swing.AbstractButton$ForwardActionEvents.actionPerformed(AbstractButton.java:1839)

at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)

at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)

at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:245)

at java.awt.Component.processMouseEvent(Component.java:5100)

at java.awt.Component.processEvent(Component.java:4897)

at java.awt.Container.processEvent(Container.java:1569)

at java.awt.Component.dispatchEventImpl(Component.java:3615)

at java.awt.Container.dispatchEventImpl(Container.java:1627)

at java.awt.Component.dispatchEvent(Component.java:3477)

at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:3483)

at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3198)

at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3128)

at java.awt.Container.dispatchEventImpl(Container.java:1613)

at java.awt.Window.dispatchEventImpl(Window.java:1606)

at java.awt.Component.dispatchEvent(Component.java:3477)

at java.awt.EventQueue.dispatchEvent(EventQueue.java:480)

at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:201)

at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:145)

at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:137)

at java.awt.EventDispatchThread.run(EventDispatchThread.java:100)

Code it warning about

PlayPause.java

public int getState(int actualstate) {

if(actualstate == PLAY_STATE){

krayaprocess.stopButton.setVisible(false);

krayaprocess.startButton.setVisible(true);

}else{

krayaprocess.stopButton.setVisible(true);

krayaprocess.startButton.setVisible(false);

}

}

Events.java

if (sel == "Exit") {

System.exit(1);

}

else if (sel == "Hierrarchy") {

TreeMap hierMenu = new TreeMap();

hierMenu.setVisible(true);

}

else if (sel=="Play"){

stopwatch.start();

playpause.STATE=1;

playpause.getState(1);

}

else if (sel =="Stop") {

stopwatch.stop();

playpause.STATE=0;

stopwatch.reset();

playpause.getState(0);

}

else if (sel=="About") {

}

I am trying to get it to hide the play or pause button when i click the other one but it keep giving me that error

Thanks

[2933 byte] By [LiamUka] at [2007-11-27 0:15:06]
# 1

This line:

java.lang.NullPointerException

at buttons.PlayPause.getState(PlayPause.java:36)

says that the error is occuring on line 36 in the class PlayPause.java. Check that line to see where you are referencing on object that doesn't exist. Use a debugger our some print statements to print out your variables to see what you're trying to reference.

hungyee98a at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...
# 2
yeah i know it's the lineskrayaprocess.stopButton.setVisible(false);krayaprocess.startButton.setVisible(true);}else{krayaprocess.stopButton.setVisible(true);krayaprocess.startButton.setVisible(false);but i know they exsist
LiamUka at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...
# 3

> yeah i know it's the lines

>

> krayaprocess.stopButton.setVisible(false);

> krayaprocess.startButton.setVisible(true);

> }else{

> krayaprocess.stopButton.setVisible(true);

> krayaprocess.startButton.setVisible(false);

>

> but i know they exsist

The error message does not lie. If it says something is null, it's null, and it's you who's mistaken. It's talking about exactly one line. Which line is that?

jverda at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...
# 4
i know it doesn't lie that why I am asking if anyone else can see the problem as i don't as i have looked at everything.well it's the first line after the if or else depending on what condition ti hits
LiamUka at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...
# 5

You mean this?

krayaprocess.stopButton.setVisible(false);

Then either krayaprocess is null or krayaprocess.stopButton is null.

Print those out there and where you think they're being set, or use a debugger, in order to trace what's going on.

When you post code, please use[code] and [/code] tags as described in [url=http://forum.java.sun.com/help.jspa?sec=formatting]Formatting tips[/url] on the message entry page. It makes it much easier to read.

jverda at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...
# 6

Ok hero, do the following EXACTLY -

#1

GO TO LINE 36

#2

Lets pretend that line is:

krayaprocess.stopButton.setVisible(false);

#3

right before that line insert:

if(krayprocess == null){ System.out.println("Look at that, i was wrong."); }

if(stopbutton == null){ System.out.println("Look at that, i was wrong."); }

#4

come back with the results

TuringPesta at 2007-7-11 22:01:30 > top of Java-index,Java Essentials,Java Programming...