This might be a long shot, but does anyone know of a way to paint the dotted line focus-rectangle on my custom component just like the current LAF components do? I'm writing a custom component and I would like it's UI delegate to look very much like the Windows 7 LAF. Thanks.
+1
A:
Should be fairly easy by using appropriate BasicStroke and then creating a rectangualar shape using createStrokedShape method.
eugener
2010-05-02 17:54:59
Thanks for the response. It may or may not use a dotted line at all. And what if the look-and-feel gets tweaked later on? I'd have to play cat-and-mouse. I was hoping there was a publicly visible method for painting my component to be deactivated just as the current look and feel (whatever it is). Might be wishful thinking.
John B.
2010-05-02 19:07:25
If you're trying to make your custom component look correct generically on any LAF then I'm afraid it is not possible. But it is possible to write specific UI for specific LAF to make it look correct.
eugener
2010-05-02 21:42:29
+1
A:
It will be tricky, but possible. E.g take a look to e.g. WindowsButtonUI. There is method called paintFocus and there are all information needed. As you can see the all values are read using UIManager.get*(string)
methods where string
is in form button.*
. This is common convention used in UI defaults table.
Rastislav Komara
2010-05-03 11:46:34
That sounds a lot like what I'm looking for. I'll try to dive in soon and take a look.
John B.
2010-05-03 18:39:23