problem with setIcon


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: problem with setIcon

  1. #1
    Join Date
    Nov 2006
    Posts
    3

    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

  2. #2
    Join Date
    Dec 2005
    Posts
    97
    i think it might be because you never initialized c1. try this
    private JButton c1 = new JButton(/*put the icon here if you wanted*/);

  3. #3
    Join Date
    Nov 2006
    Posts
    3

    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

  1. Problem with Search
    By Irina in forum ASP.NET
    Replies: 0
    Last Post: 11-29-2002, 11:47 PM
  2. Replies: 0
    Last Post: 12-13-2001, 01:06 PM
  3. a problem with font and language
    By Roseta in forum VB Classic
    Replies: 0
    Last Post: 11-14-2001, 04:24 AM
  4. Arabic problem view
    By Ayman in forum VB Classic
    Replies: 0
    Last Post: 04-03-2000, 02:08 AM
  5. Problem with CryptoAPI and JCE
    By Jason Bock in forum VB Classic
    Replies: 0
    Last Post: 03-21-2000, 07: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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center