problem with stIcon()
Hi,
I am developing an application which needs to dynamically show whether a host is up or down.I have used buttons on which i am pasting the icon indicating up or down.So, when a node is down, I am replacing the icon that indicates up with the icon that indicates down using setIcon() function.But instead of changing the icon a NullPointerException is generated.For example,
private JButton c1;
JButton c1 = new JButton();
Icon bug = new ImageIcon("image/coms1.gif");//this image is for up
Icon bug3= new ImageIcon("image/computer.gif");//for down
c1.setIcon(bug);
if(node is down)
c1.setIcon(bug3);
Thanks for any help.
jerico
[697 byte] By [
Rajkhowaa] at [2007-10-3 9:38:06]

Normally you would get a message giving you the exact line number where the exception was thrown:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at myPackage.MyClass(MyClass.java:38) <
Then you can easily go to your source code and determine which pointer is null (node/bug/bug3/...)
and why it has not been initialized or why it has been set to null.
The line where the error message was pointing to was:-if(node is down) c1.setIcon(bug3);// this lineI forgot to mention that the error is not shown during compiling, but during runtime.Any help will be greatly appreciated as I cant proceed without solving this