Java 如何自定义 JFrame 上的标题栏?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2781987/
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
How can I customize the title bar on JFrame?
提问by Jonas
I would like to have a customized title bar in my Java Swing desktop application. What is the best way to do that? I can use a "Swing-title bar" by using the following code in the constructor for my JFrame:
我想在我的 Java Swing 桌面应用程序中有一个自定义的标题栏。最好的方法是什么?我可以通过在 JFrame 的构造函数中使用以下代码来使用“Swing-title bar”:
this.setUndecorated(true);
this.getRootPane().setWindowDecorationStyle(JRootPane.FRAME);
But how do I customize it? Is there any UI delegatesthat I can override or do I have to implement my own title bar from scratch?
但是我如何自定义它?是否有我可以覆盖的UI 委托,或者我是否必须从头开始实现我自己的标题栏?
I want something like Lawson Smart Office:
我想要像 Lawson Smart Office 这样的东西:
采纳答案by Kirill
You can see an example in Substance look-and-feel(mirrored source). Search the code for SubstanceRootPaneUI and SubstanceTitlePane. The implementation depends on other classes in Substance, and will not be easy to reuse outside the specific library - nor is it meant to.
您可以在Substance 外观(镜像源)中看到一个示例。搜索 SubstanceRootPaneUI 和 SubstanceTitlePane 的代码。实现依赖于 Substance 中的其他类,并且不容易在特定库之外重用 - 也不是故意的。