Custom design for Close/Minimize buttons on JFrame

前端 未结 4 948
抹茶落季
抹茶落季 2021-01-15 16:21

I would like to apply my own close and minimize buttons. Is there any way to change the JFrame design?

4条回答
  •  旧时难觅i
    2021-01-15 17:08

    The only thing I'm aware that can be done is to add a WindowListener to the JFrame and handle closing events in that listener. You can make virtually anything, like displaying dialogs or even cancelling the closing of the JFrame.

    See this tutorial for more details about how to write such listeners.

    As for minimizing: as far as I know, there is no way to control or modify such behaviour, it's completely controlled by the operating system.

    The only way to change the aspect of the minimize/close/maximize buttons is to use a custom LookAndFeel and setting JFrame.setDefaultLookAndFeelDecorated (true);.

提交回复
热议问题