Swing JToggleButton UI Look and Feel question

From: James Kimble (jkimble_at_one.net)
Date: 03/23/05


Date: 23 Mar 2005 12:42:57 -0800

I've been given the task up updating the appearence (ie color
when selected or not) of some JToggleButtons on a fairly large
application and it seems like a really bad idea to do this via
btn.setBackground or btn.setForeground etc... I know it should be done
via a UIManager to uniformly set the look and feel of these buttons to
something different than the default. The problem I
have is that I have no idea how to do this and I haven't been
able to find anything useful on the internet.

The original author did some of this stuff but changing doesn't
seem to change the appearance of the app and I have to wonder if
it's doing anything at all.

---------------------------------------------------------------
    UIDefaults def = UIManager.getDefaults();

    Object buttonBorder =
      new UIDefaults.ProxyLazyValue(
          "javax.swing.plaf.basic.BasicBorders",
          "getButtonBorder");

    def.putDefaults(new Object[]
    {
      "Button.border", buttonBorder,
      "ProgressBar.selectionForeground", Color.black,
      "ProgressBar.selectionBackground", Color.black,
      "Panel.background", Color.gray,
      "Button.background", Color.gray,
      "Label.background", Color.gray,
    } );
------------------------------------------------------------

Can someone give me a hint or point me to a useful resource
for this type of thing. How hard can it possibly be?

Any help much appreciated....