eh

import javax.swing.*;
public class Main{
public static void main(String[] args) {
JFrame frame=new JFrame("ChesSouhay");
frame.setSize(720, 720);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

ImageIcon icon=new ImageIcon("icon.png");
frame.setIconImage(icon.getImage());
}
}
public class Main{
public static void main(String[] args) {
JFrame frame=new JFrame("ChesSouhay");
frame.setSize(720, 720);
frame.setResizable(false);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);

ImageIcon icon=new ImageIcon("icon.png");
frame.setIconImage(icon.getImage());
}
}
the icon is not changing i feel like something is wrong with my project file .-.
No description
9 Replies
JavaBot
JavaBot•2y ago
⌛ This post has been reserved for your question.
Hey @MoonSouhayl! 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.
Kyo-chan
Kyo-chan•2y ago
The file probably can't be found with just new ImageIcon("icon.png"). That doesn't tell where it is As a project is typically packaged as a .jar or otherwise runnable file in the end, files should be read as resources rather than files on the filesystem anyway
MoonSouhayl
MoonSouhaylOP•2y ago
sooo what i should replace the "icon.png" with ? 🙂
Kyo-chan
Kyo-chan•2y ago
Have you even made one google search?
MoonSouhayl
MoonSouhaylOP•2y ago
ye but i never find an answer :idontunderstand:
Kyo-chan
Kyo-chan•2y ago
How to Use Icons (The Javaâ„¢ Tutorials >
Creatin...
This Swing Java Tutorial describes developing graphical user interfaces (GUIs) for applications and applets using Swing components
Kyo-chan
Kyo-chan•2y ago
I find it weird that it took you less than 40 seconds to make all the research you needed to know you've not found what you need by yourself But eh, weird as it is, that happened to me sometimes
MoonSouhayl
MoonSouhaylOP•2y ago
nah it took 48s and also i don't like solutions that just add so many things i didn't reach
JavaBot
JavaBot•2y ago
💤 Post marked as dormant
This post has been inactive for over 300 minutes, thus, it has been archived. If your question was not answered yet, feel free to re-open this post or create a new one.

Did you find this page helpful?