Java中如何调整JFrame边框粗细
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
默认情况下,边框由本机窗口系统处理。但在 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 theUIManager
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.