如何在 Java 中隐藏 JFrame 窗口上的默认最小化/最大化和关闭按钮?

2022-01-24 00:00:00 user-interface java swing jframe

我想知道是否可以创建一个没有默认最大化/最小化(-) 和关闭(x) 按钮的 JFrame 窗口!我在每一帧上都添加了自定义按钮,这样用户就不必乱用窗口右上角的默认按钮了!

I would like to know if it is possible to create a JFrame window which has no default maximize/minimize(-) and close(x) buttons! I have added custom buttons on each frame so that the user does not have to mess around with the default ones on the top right corner of the window!

推荐答案

你可以使用JWindow 因为默认情况下是 un_decorated,但您可以 setUndecorated() 用于 JFrame/JDialog

You can use JWindow because is by default un_decorated, but you can setUndecorated() for JFrame/JDialog

另一种方法是

  • 实现 WindowListener

setDefaultCloseOperations

相关文章