java 未修饰的 JDialog 边框
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17413658/
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
Undecorated JDialog border
提问by Mark
I have a question regarding the border around an undecorated JDialog
using the Metal L&F
.
我有一个关于JDialog
使用Metal L&F
.
Look at this picture to see the border that is on this window:
看看这张图片,看看这个窗口上的边框:
I'm trying to figure out how to either get rid of or change the color of the blue border around the very outside of the JDialog
. I looked at the UI defaults for the Look & Feel
but I wasn't able to come up with any that worked for this.
我试图弄清楚如何摆脱或更改JDialog
. 我查看了 的 UI 默认值,Look & Feel
但我无法想出任何适用于此的。
Does anybody have any ideas on how to get rid of that border?
有人对如何摆脱边界有任何想法吗?
Thanks!
谢谢!
回答by camickr
You need to change the Border
of the root pane:
您需要更改Border
根窗格的 :
getRootPane().
setBorder( BorderFactory.createLineBorder(Color.RED) );
回答by user2526311
If you want to get rid of it you can use
如果你想摆脱它,你可以使用
frame.setUndecorated(true);
frame.getRootPane().setWindowDecorationStyle(JRootPane.NONE);
To change the look of it from the Java style to the windows style you can use
要将其外观从 Java 样式更改为 Windows 样式,您可以使用
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
回答by Maroun
You can do something like this:
你可以这样做:
((JPanel)getContentPane()).setBorder(BorderFactory.createLineBorder(Color.BLUE));
You can try to do this in order to change the most outsude border:
您可以尝试这样做以更改最外面的边框:
getRootPane().setBorder(BorderFactory.createLineBorder(Color.BLUE));
Is this what you want to do?
这是你想做的吗?