Swing:从对话框的按钮中移除焦点边框 [英] Swing: remove focus border from dialogues' buttons

查看:225
本文介绍了Swing:从对话框的按钮中移除焦点边框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何从对话中的按钮中删除此灰色边框?

I wonder how can I remove this grey border from buttons in dialogues?

对于我发现的简单JButtons一个解决方案 - 只需使用 button.setFocusPainted(false);
但是有一种简单的方法可以对所有对话中的所有按钮执行相同的操作吗?
我试图查看UIManager属性,但似乎没有合适的参数。

For simple JButtons I found a solution - just use button.setFocusPainted(false); But is there a simple way to perform the same for all buttons in all dialogues? I tried to look through UIManager properties, but it seems that there are no suitable parameters there.

谢谢提前!

推荐答案


  • 来自 JButtons API 你可以使用 JButton.setFocusable() JButton.setBorderPainted(false);

    来自 UIManager 必须覆盖密钥(对整个JVM实例有效)

    from UIManager have to override key (valid for whole JVM instance)

    UIDefaults defaults = UIManager.getLookAndFeelDefaults();
    defaults.put("Button.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
    




    • 我建议更改颜色透明度(上午代码中的第4个参数)到另一个更体面的颜色,否则你不能看到任何`JButtons

      • I'd to suggest to change Color with transparency (4th paramater in a.m. code) to another more decent Color, otherwise you can't to see focus for any of `JButtons
      • 这篇关于Swing:从对话框的按钮中移除焦点边框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆