Java swing metal JButton focus border size

a 夏天 提交于 2021-01-29 03:03:26

问题


If I set Metal theme for Swing GUI, JButton border is painted around the whole button, but focus border is painted only around JButton's text and icon, so if text size is smaller than button size, the border appears inside button. Most replies to this problem simply suggest to disable global focus border painting by

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

or per-button by jButton.setFocusPainted(false);

But I actually want focus border to be painted - like in Nimbus LAF around the whole button. I suppose I need to override focus painter with default one for Button.border, but can't find which one. Maybe someone can help me?

来源:https://stackoverflow.com/questions/55087137/java-swing-metal-jbutton-focus-border-size

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!