Changing Icon of Application in IntelliJ with Java Swing on MacOS
Why does the icon of my app not change with IntelliJ on Mac? I find Swing to barely change anything on Mac, like the title bar. Here is the code I'm using:
frame = new JFrame("File Uploader");
ImageIcon appIcon = new ImageIcon("src/assets/IMGs/MetaTune_Icon.png");
if (appIcon.getImageLoadStatus() == MediaTracker.COMPLETE) {
System.err.println("Loaded image: ");
}
frame.setIconImage(appIcon.getImage());
I get no errors and I also get "loaded image" but no changes.
6 Replies
⌛
This post has been reserved for your question.
Hey @Just Jack! Please useTIP: Narrow down your issue to simple and precise questions to maximize the chance that others will reply in here./close
or theClose Post
button above when your problem is solved. Please remember to follow the help guidelines. This post will be automatically closed after 300 minutes of inactivity.
Please format your code to make it more readable. For java, it should look like this:
Stack Overflow
Setting the default application icon image in Java swing on OS X
I'm trying to set the icon image for a Jar file:
setIconImage(new ImageIcon(getClass().getResource("logo.png")).getImage());
When running in Mac OS X 10.7.4 I get the following error:
Jun 28 15:...
Also consider using
new ImageIcon(getClass().getClassLoader().getResource("assets/IMGs/MetaTune_Icon.png"))
instead of new ImageIcon("src/assets/IMGs/MetaTune_Icon.png")
see https://stackoverflow.com/q/20389255/10871900 and https://stackoverflow.com/q/15749192/10871900 for why this is the case
Stack Overflow
Reading a resource file from within jar
I would like to read a resource from within my jar like so:
File file;
file = new File(getClass().getResource("/file.txt").toURI());
BufferedReader reader = new BufferedReader(new FileRea...
Stack Overflow
How do I load a file from resource folder?
My project has the following structure:
/src/main/java/
/src/main/resources/
/src/test/java/
/src/test/resources/
I have a file in /src/test/resources/test.csv and I want to load the file from a ...
💤
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.
In case your post is not getting any attention, you can try to use /help ping
.
Warning: abusing this will result in moderative actions taken against you.