#JFrame ImageIcon not appearing?

28 messages · Page 1 of 1 (latest)

abstract yoke
#

https://gyazo.com/87ab8fc07a753ab5fc5e9373e80ee87d

import javax.swing.ImageIcon;
import javax.swing.JFrame;

public class Frame{

public static void main(String[]args) {
    
    
    
    JFrame frame = new JFrame();
    frame.setTitle("Titel");
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setResizable(false);
    frame.setSize(420,420);
    frame.setVisible(true);
    
    ImageIcon image = new ImageIcon("mary.jpg");
    frame.setIconImage(image.getImage());
    
}

}

onyx urchinBOT
#

This post has been reserved for your question.

Hey @abstract yoke! Please use /close or the Close Post button above when you're finished. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.

TIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here.

viral urchin
#

Are you using an IDE

#

How are you running it

abstract yoke
#

it is in a folder on my desktop, i made a copy into the package, im using eclipse

viral urchin
#

Try move mary into default package

#

Sorry never mind you can't do that

#

So mary is inside src?

abstract yoke
#

I just dropped into the default package

#

Needs to be in the src folder instead?

viral urchin
#

Try with default package. Not sure what that will do really

#

And src

abstract yoke
#

I've tried dragging it into the src and then also tried in the default package, still just gives me the standard icon

#

is it not allowed to have .jpg files or something?

viral urchin
#

I think eclipse is funny about resources inside source dirs

abstract yoke
#

I am watching a guide on youtube and he did the exact same thing I am doing, only difference is that for him it is a .png picture instead

viral urchin
#

Try a png

viral urchin
#

Icons in swing are kinda hard to figure out. It just silently doesn't do what you want it to do lol

abstract yoke
#

I'm really new to coding so i dont understand what that link means that you sent

#

I figured it out, tysm for helping