Search code examples
javaswingfavicon

Favicon in JFrame


I am developing a small project using Java Swing. I am using jdk 7 on windows 7.

I have the main window of my application (JFrame) and of course it has a "favicon" which I set (it doesn't even matter if it was the default java logo).

My question is: Is there any possibility to disable the click on favicon ? When I click I get that menu which is specific to all windows applications. Close, minimize etc.

I would like to ignore that click. I have searched a while on the internet but I found no answer, it seems like I am the first person looking for this.

Thanks.


Solution

  • To get rid of the menu set the frame to be undecorated (see Frame.setUndecorated) but then you'll lose the title bar and ability to reposition the frame using the mouse. Not such a great tradeoff.

    A possible solution suggested by this question:

    Removing a Frame's title bar keeping the resize mechanims - Java

    is to use a com.jidesoft.swing.ResizableFrame that's undecorated. It sounds like you'll lose the title bar but still be able to resize the dialog.

    Another option is to "hide" the icon, e.g.:

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

    but the menu will still be present.

    Why do you want to get rid of the menu? It's best to work within the look and feel of the OS and not redefine the user experience.