I wonder how can I remove this grey border from buttons in dialogues?
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.
Thanks in advance!
from
JButtons API
you can to useJButton.setFocusable()
and withJButton.setBorderPainted(false);
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)));
- I'd to suggest to change
Color
withtransparency
(4th paramater in a.m. code) to another more decentColor
, otherwise you can't to see focus for any of `JButtons
What about
JButton.setFocusPainted(false)
Goombert
Here's a global fix so you don't have to do it manually for every control. From my other post: Disable JButton focus border
// Removes the dotted border around controls which is not consistent with Windows
UIManager.put("Button.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
UIManager.put("ToggleButton.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
// ways to remove it from other controls...
UIManager.put("CheckBox.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
UIManager.put("TabbedPane.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
UIManager.put("RadioButton.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
UIManager.put("Slider.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
// figure out combobox
UIManager.put("ComboBox.focus", new ColorUIResource(new Color(0, 0, 0, 0)));
来源:https://stackoverflow.com/questions/13422642/swing-remove-focus-border-from-dialogues-buttons