Remove default JFrame icon

In my JFrame, I have a default coffee icon. I want to delete it. But when I do setIconImage (null), it does not work. Can someone tell me a decision on how to completely remove the icon

+7
source share
4 answers

Create an icon consisting of one pixel (preferably transparent) and use it. If you need such an icon, contact me. I will send you.

+4
source

It is always useful to keep a copy of the Java source code . The code for java.awt.Window (JFrame superclass) has the following code for setIconImage :

 public void setIconImage(Image image) { ArrayList<Image> imageList = new ArrayList<Image>(); if (image != null) { imageList.add(image); } setIconImages(imageList); } 

You can see that transmitting a null image is the same as doing nothing, so you will need to transfer an image to get rid of a cup of coffee. Since others have suggested using a 1 x 1 transparent badge, this is your best bet. Here is the code to create the icon:

 Image icon = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB_PRE); myFrame.setIconImage(icon); 
+22
source

You can set the image icon to a transparent image that will remove a cup of coffee. I do not believe that otherwise you can get rid of the default icon.

+1
source

You can just use gimp or photoshop, or even draw and create 1x1px, a transparent image, export it (.png or .jpg, doesn't it matter?). Then apply it:

 ImageIcon frameIcon = new ImageIcon("files\yourfile.png"); frame.setIconImage(frameIcon.getImage()); 

It should be good.

0
source

Source: https://habr.com/ru/post/893841/


All Articles