On Sep 30, 2008, at 6:53 AM, Ken Orr wrote:
When creating a button like this:
JToggleButton button = new JToggleButton("Java Button");
button.setFocusable(false);
button.putClientProperty("JButton.buttonType", "square");
there is a 4 pixel border added around the button for the focus
ring. What is the recommended way to remove this border? Adding it
to a panel with a negative border?
JPanel panel = new JPanel();
panel.setBorder(BorderFactory.createEmptyBorder(-4,-4,-4,-4);
panel.add(button);
Unfortunately no, there is no way to remove the focus ring border at
this time without hacking around it.
We do have a feature request to allow components to remove the extra
insets for focus rings. I'm not sure keying off of
setFocusable(false) is necessarily the right thing to do, but I'd be
happy to hear any suggestions (another client property,
setFocusable(false), size constraints, any other kind of hinting?).
Sorry,
Mike Swingler
Java Runtime Engineer
Apple Inc.