java JFrame.setDefaultLookAndFeelDecorated(true);

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/139088/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-29 11:10:11  来源:igfitidea点击:

JFrame.setDefaultLookAndFeelDecorated(true);

javauser-interfaceswing

提问by Waseem

when i use setDefaultLookAndFeelDecorated(true) method in Java why is the Frame appear FullScreen when i maximize the Frame ? and how can i disaple the FullScreen mode in this method ?

当我在 Java 中使用 setDefaultLookAndFeelDecorated(true) 方法时,为什么当我最大化框架时框架出现全屏?以及如何在此方法中禁用全屏模式?

采纳答案by Angelo van der Sijpt

Setting setDefaultLookAndFeelDecoratedto true causes the decorations to be handled by the look and feel; this means that a System look-and-feel on both Windows and Mac (I have no Linux at hand now) retains the borders you would expect them of a native window, e.g. staying clear of the taskbar in Windows.

设置setDefaultLookAndFeelDecorated为 true 会导致装饰由外观处理;这意味着 Windows 和 Mac 上的系统外观(我现在手头没有 Linux)保留了您期望它们在本机窗口中的边界,例如在 Windows 中远离任务栏。

When using the Cross Platform look-and-feel, a.k.a. Metal, which is the default on Windows, the Windows version will take over the entire screen, making it look like a full-screen window. On Mac, the OS refuses to give away its own titlebar, and draws a complete Metal frame (including the title bar) in a Mac-native window.

当使用跨平台外观,又名 Metal,这是 Windows 的默认设置时,Windows 版本将接管整个屏幕,使其看起来像一个全屏窗口。在 Mac 上,操作系统拒绝泄露自己的标题栏,并在 Mac 原生窗口中绘制了一个完整的 Metal 框架(包括标题栏)。

So, in short, if you want to make sure the taskbar gets respected, use the Windows system look-and-feel on Windows. You can set it by using something like

因此,简而言之,如果您想确保任务栏得到尊重,请在 Windows 上使用 Windows 系统外观。您可以使用类似的东西来设置它

UIManager.setLookAndFeel((LookAndFeel) Class.forName(UIManager.getCrossPlatformLookAndFeelClassName()).newInstance());

回答by pfranza

If you don't want your JFrame to be maximize-able then then call .setResizable(false); on it.

如果您不希望 JFrame 可以最大化,则调用 .setResizable(false); 在上面。