tags:

views:

22

answers:

2

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
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.
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
+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
That sounds a lot like what I'm looking for. I'll try to dive in soon and take a look.
John B.