Java中如何调整JFrame边框粗细

发布于 2024-08-13 00:44:29 字数 127 浏览 5 评论 0原文

我正在使用 Vista,我在 Win XP 上运行的旧 Java 应用程序有细边框,大约 2 像素厚,但现在在 Vista 上,边框默认为粗线,可能是 6,7 像素厚,我可以在 Java 中指定我的边框有多粗吗? JFrame 边框应该是?

I'm using Vista, my old Java app ran on Win XP has thin borders, about 2 pixels thick, but now on Vista, the borders deafults to thick lines, maybe 6,7 pixels thick, can I specify in Java how thick my JFrame borders should be ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

烂人 2024-08-20 00:44:30

默认情况下,边框由本机窗口系统处理。但在 JFrame API 中有一个方法 setDefaultLookAndFeelDecolated(boolean)。它表示如果设置为 true并且如果当前的外观支持它,它将使用外观来绘制边框、标题和按钮。我从来没有尝试过这个,因为我不知道哪种外观和感觉支持装饰。第一件事是找到一个这样做的,然后通过 UIManager 或命令行 -Ddefault.laf 参数进行设置,并通过JFrame方法。

如果您使用此选项,您可能会得到非标准外观的窗户装饰。鉴于 Vista 的一些养眼效果(将鼠标悬停在按钮和半透明标题栏上时会发光),您确定要这样做吗?

另一种选择是使用 JFrame.setUndecorated(boolean) 方法并自己处理边框、标题栏等的渲染,但这可能更加困难。

By default borders are handled by the native windowing system. But in the JFrame API there is a method setDefaultLookAndFeelDecorated(boolean). It says that if set to true and if the current look and feel supports it, it will use the look and feel to draw the borders, title and buttons. I haven't ever tried this, since I don't know which look and feels support decoration. The first thing would be to find one that does, then set that via the UIManager or command-line -Ddefault.laf argument, and turn on look and feel decoration via the JFrame method.

If you use this option though, you'll probably get non-standard looking window decoration. Given the little bits of Vista eye candy (glow on hover over the buttons and the translucent title bar), are you sure you want to do that?

Another option is to use the JFrame.setUndecorated(boolean) method and handle rendering of borders, title bar, etc. yourself, but that's probably even more difficult.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文