• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1137
  • Last Modified:

Java cup of tea icon

Hi experts
How can i replace the small java cup of tea icon that shows on JFrames with my own icon say in .jpg format ? How do i know the actual size of this tiny image and in which format is it?
0
SimpleJava
Asked:
SimpleJava
  • 6
  • 4
  • 2
1 Solution
 
CEHJCommented:
Try

setIconImage(Toolkit.getDefaultToolkit().getImage(this.getClass().getResource("images/your.jpg")));
0
 
riaancorneliusCommented:
>
just change the imageicon for the frame, it get's scaled, but 16X16 pixels is usualy good
0
 
riaancorneliusCommented:
btw, java will load most of the popular image formats using CEHJ's method
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SimpleJavaAuthor Commented:
Thanks but i'm getting an uncaught error fetching image which says something about java.lang.NullPointerException
0
 
SimpleJavaAuthor Commented:
I have the image in the same directory as the main class to give some further information
0
 
SimpleJavaAuthor Commented:
> just change the image icon for the frame
riaancornelius where is the image icon for the frame located ?
0
 
CEHJCommented:
try

setImageIcon(new ImageIcon("your.jpg").getImage());
0
 
SimpleJavaAuthor Commented:
method setImageIcon() cannot be resolved!!!!
0
 
SimpleJavaAuthor Commented:
>> correction your setImageIcon() is supposed to be setIconImage().=)
i guess it was a typo.
Works fine. Thank you CEHJ.
But where is the image for the frame located ?
0
 
CEHJCommented:
>>But where is the image for the frame located ?

Not sure but wouldn't be surprised if it were in a runtime binary
0
 
SimpleJavaAuthor Commented:
Thank you. Will try and find out.
0
 
CEHJCommented:
:-)
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

  • 6
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now