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: Can you help me with this Java GUI IconImage

  1. #1
    Junior Member
    Join Date
    Aug 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Can you help me with this Java GUI IconImage

    package projects;

    import javax.swing.*;

    public class Projects {
    public static void main(String[] args) {

    JFrame frame = new JFrame();
    frame.setSize(500,500);
    frame.setVisible(true);
    frame.setResizable(true);

    ImageIcon image = new ImageIcon("logo.PNG");
    frame.setIconImage(image.getImage());


    }

    }

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

    Default Re: Can you help me with this Java GUI IconImage

    What happens when you compile and execute the code?
    If there are any error messages, copy the full text and paste it here.
    Where is the file: logo.PNG located relative to the current directory when the program is executed?
    The posted code requires that the file be in the current directory to be found.

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Aug 2021
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Can you help me with this Java GUI IconImage

    I didn't get any errors but the icon image remains same as java logo

Similar Threads

  1. IconImage
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 1
    Last Post: December 5th, 2010, 01:07 PM

Tags for this Thread