-
problem with setIcon
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;
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
-
i think it might be because you never initialized c1. try this
private JButton c1 = new JButton(/*put the icon here if you wanted*/);
-
setIcon()
Oh,I forgot to mention that line.I initialized it like u said.But it is still not working.I am using GridBagLayout() layout manager.
Jerico
Similar Threads
-
By Irina in forum ASP.NET
Replies: 0
Last Post: 11-29-2002, 10:47 PM
-
Replies: 0
Last Post: 12-13-2001, 12:06 PM
-
By Roseta in forum VB Classic
Replies: 0
Last Post: 11-14-2001, 03:24 AM
-
By Ayman in forum VB Classic
Replies: 0
Last Post: 04-03-2000, 01:08 AM
-
By Jason Bock in forum VB Classic
Replies: 0
Last Post: 03-21-2000, 06:48 PM
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks