Hello,
when you move the pointer across the edge of a default JButton, the border changes, between one-pixel wide, and 3-pixel wide shaded. If you want to do this effect yourself by hand, how - is there a method to do this?
Before you ask "why" - this is the context, if you care to know why I need this:
I had written here yesterday that JButton on a Mac looks way too long for the label. If I have a label "?", the button is about 100 pixels! This has something to do with the Mac L&F...
So I figured out, that if I set the border on the button, then the button is tight around the label, on both PC and Mac. Which is good, but ... now it's too tight. So I wanted to create margins - and of course, you can't have both setMargin and setBorder on a JButton (per docs). You have to make a compound border with an empty inner border.
JButton helpButton = new JButton("?");
Border innerBorder =
BorderFactory.createEmptyBorder( 3, 3, 2, 3 );
Border outerBorder = new LineBorder(Color.gray, 1, false);
Border compoundBorder =
BorderFactory.createCompoundBorder( outerBorder, innerBorder );
helpButton.setBorder(compoundBorder);
OK, now it's looking good, but, the only problem is it lost its rollover effect, when you move your pointer across the border, nothing changes. So I guess I need to do this by hand as well. Maybe there is a method for it, rather than have to implement mouse event handlers and such.