Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: JLabel image?

  1. #1
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default JLabel image?

    Im trying to draw an image using JLabel.

    heres my code
    private JLabel title = new JLabel(new ImageIcon("banner.png"));

    I am calling it later on
    funcpanel.add(title);

    But the image is never drawn. I have it in the proper directory why is it not drawing?


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: JLabel image?

    Lots of reasons. Your 2 lines of code are not enough to say which one.
    Have to tested that the program is finding the image? Use a File object with the path to the image and print its absolute path and check if the printed path is where the image is.

  3. The Following User Says Thank You to Norm For This Useful Post:

    frozen java (September 28th, 2011)

  4. #3
    Member
    Join Date
    Jan 2011
    Posts
    88
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: JLabel image?

    i got it! thanks!

Similar Threads

  1. Everything but JLabel is displaying
    By Jacksontbh in forum What's Wrong With My Code?
    Replies: 2
    Last Post: July 3rd, 2011, 10:30 PM
  2. A problem with JLabel!
    By niklas in forum AWT / Java Swing
    Replies: 5
    Last Post: December 19th, 2010, 05:51 AM
  3. A problem with JLabel!
    By niklas in forum Member Introductions
    Replies: 1
    Last Post: December 14th, 2010, 06:03 PM
  4. Cannot update Jlabel in JApplet
    By rin in forum Java Applets
    Replies: 2
    Last Post: April 17th, 2010, 08:21 AM
  5. how to output using JLabel?
    By qaromi in forum AWT / Java Swing
    Replies: 1
    Last Post: August 30th, 2009, 02:09 PM