gt:                     Object oldVal = m.invoke(c,null);
context: /*
   * $Id: BasicTitledPanelUI.java,v 1.11 2005/10/26 11:44:31 kleopatra Exp $
   *
   * Copyright 2004 Sun Microsystems, Inc., 4150 Network Circle,
   * Santa Clara, California 95054, U.S.A. All rights reserved.
   *
   * This library is free software; you can redistribute it and/or
   * modify it under the terms of the GNU Lesser General Public
   * License as published by the Free Software Foundation; either
   * version 2.1 of the License, or (at your option) any later version.
   * 
   * This library is distributed in the hope that it will be useful,
   * but WITHOUT ANY WARRANTY; without even the implied warranty of
   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   * Lesser General Public License for more details.
   * 
   * You should have received a copy of the GNU Lesser General Public
   * License along with this library; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   */
  
  package org.jdesktop.swingx.plaf.basic;
  
  import java.awt.BorderLayout;
  import java.awt.Color;
  import java.awt.Container;
  import java.awt.Font;
  import java.awt.GradientPaint;
  import java.awt.Graphics;
  import java.awt.Graphics2D;
  import java.awt.GridBagConstraints;
  import java.awt.GridBagLayout;
  import java.awt.Image;
  import java.awt.Insets;
  import java.beans.BeanInfo;
  import java.beans.Introspector;
  import java.beans.PropertyChangeEvent;
  import java.beans.PropertyChangeListener;
  import java.beans.PropertyDescriptor;
  import java.lang.reflect.Method;
  import java.util.logging.Level;
  import java.util.logging.Logger;
  
  import javax.swing.BorderFactory;
  import javax.swing.ImageIcon;
  import javax.swing.JComponent;
  import javax.swing.JLabel;
  import javax.swing.UIManager;
  import javax.swing.plaf.UIResource;
  
  import org.jdesktop.swingx.JXPanel;
  import org.jdesktop.swingx.JXTitledPanel;
  import org.jdesktop.swingx.plaf.TitledPanelUI;
  
  
  /**
   * All TitledPanels contain a title section and a content section. The default
   * implementation for the title section relies on a Gradient background. All
   * title sections can have components embedded to the &quot;left&quot; or
   * &quot;right&quot; of the Title.
   *
   * @author Richard Bair
   * @author Jeanette Winzenburg
   * 
   */
  public abstract class BasicTitledPanelUI extends TitledPanelUI {
      private static final Logger LOG = Logger.getLogger(BasicTitledPanelUI.class
              .getName());
      
  	/**
  	 * JLabel used for the title in the Title section of the JTitledPanel.
  	 */
  	private JLabel caption;
  	/**
  	 * The Title section panel.
  	 */
  	private JGradientPanel topPanel;
      /**
       * Listens to changes in the title of the JXTitledPanel component
       */
      private PropertyChangeListener titleChangeListener;
      /**
       * The JXTitledPanel peered with this UI
       */
      protected JXTitledPanel titledPanel;
      private JComponent left;
      private JComponent right;
      
      /** Creates a new instance of BasicTitledPanelUI */
      public BasicTitledPanelUI() {
      }
  
      /**
       * Configures the specified component appropriate for the look and feel.
       * This method is invoked when the <code>ComponentUI</code> instance is being installed
       * as the UI delegate on the specified component.  This method should
       * completely configure the component for the look and feel,
       * including the following:
       * <ol>
       * <li>Install any default property values for color, fonts, borders,
       *     icons, opacity, etc. on the component.  Whenever possible, 
       *     property values initialized by the client program should <i>not</i> 
       *     be overridden.
       * <li>Install a <code>LayoutManager</code> on the component if necessary.
       * <li>Create/add any required sub-components to the component.
       * <li>Create/install event listeners on the component.
       * <li>Create/install a <code>PropertyChangeListener</code> on the component in order
       *     to detect and respond to component property changes appropriately.
       * <li>Install keyboard UI (mnemonics, traversal, etc.) on the component.
       * <li>Initialize any appropriate instance data.
       * </ol>
       * @param c the component where this UI delegate is being installed
       *
       * @see #uninstallUI
       * @see javax.swing.JComponent#setUI
       * @see javax.swing.JComponent#updateUI
       */
      public void installUI(JComponent c) {
        
          titledPanel = (JXTitledPanel)c;
          
          installProperty(titledPanel, "titleForeground", UIManager.getColor("JXTitledPanel.title.foreground"));
          installProperty(titledPanel, "titleDarkBackground", UIManager.getColor("JXTitledPanel.title.darkBackground"));
          installProperty(titledPanel, "titleLightBackground", UIManager.getColor("JXTitledPanel.title.lightBackground"));
          installProperty(titledPanel, "titleFont", UIManager.getFont("JXTitledPanel.title.font"));
  
          
        caption = createAndConfigureCaption(titledPanel);
        topPanel = createAndConfigureTopPanel(titledPanel);
          fillTopPanel();
          titledPanel.setLayout(new BorderLayout());
          titledPanel.add(topPanel, BorderLayout.NORTH);
  		titledPanel.setBorder(BorderFactory.createRaisedBevelBorder());
  		titledPanel.setOpaque(false);
          
          installListeners();
          
      }
  
      private void fillTopPanel() {
          topPanel.add(caption, new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(4, 12, 4, 12), 0, 0));
          if (titledPanel.getClientProperty(JXTitledPanel.RIGHT_DECORATION) instanceof JComponent) {
              addRightDecoration((JComponent) titledPanel.getClientProperty(JXTitledPanel.RIGHT_DECORATION));
          }
          if (titledPanel.getClientProperty(JXTitledPanel.LEFT_DECORATION) instanceof JComponent) {
              addLeftDecoration((JComponent) titledPanel.getClientProperty(JXTitledPanel.LEFT_DECORATION));
          }
      }
  
      private JGradientPanel createAndConfigureTopPanel(JXTitledPanel titledPanel) {
          JGradientPanel topPanel = createTopPanel(titledPanel);
          topPanel.setBorder(BorderFactory.createEmptyBorder());
          topPanel.setLayout(new GridBagLayout());
          return topPanel;
      }
  
      private JLabel createAndConfigureCaption(JXTitledPanel titledPanel) {
          JLabel caption = new JLabel(titledPanel.getTitle());
          caption.setFont(titledPanel.getTitleFont());
          caption.setForeground(titledPanel.getTitleForeground());
          return caption;
      }
      /**
       * Reverses configuration which was done on the specified component during
       * <code>installUI</code>.  This method is invoked when this 
       * <code>UIComponent</code> instance is being removed as the UI delegate 
       * for the specified component.  This method should undo the
       * configuration performed in <code>installUI</code>, being careful to 
       * leave the <code>JComponent</code> instance in a clean state (no 
       * extraneous listeners, look-and-feel-specific property objects, etc.).
       * This should include the following:
       * <ol>
       * <li>Remove any UI-set borders from the component.
       * <li>Remove any UI-set layout managers on the component.
       * <li>Remove any UI-added sub-components from the component.
       * <li>Remove any UI-added event/property listeners from the component.
       * <li>Remove any UI-installed keyboard UI from the component.
       * <li>Nullify any allocated instance data objects to allow for GC.
       * </ol>
       * @param c the component from which this UI delegate is being removed;
       *          this argument is often ignored,
       *          but might be used if the UI object is stateless
       *          and shared by multiple components
       *
       * @see #installUI
       * @see javax.swing.JComponent#updateUI
       */
      public void uninstallUI(JComponent c) {
          
          uninstallListeners(titledPanel);
          // JW: this is needed to make the gradient paint work correctly... 
          // LF changes will remove the left/right components...
          topPanel.removeAll();
          titledPanel.remove(topPanel);
          titledPanel.putClientProperty(JXTitledPanel.LEFT_DECORATION, left);
          titledPanel.putClientProperty(JXTitledPanel.RIGHT_DECORATION, right);
          caption =  null;
          topPanel = null;
          titledPanel = null;
          left = null;
          right = null;
      }
  
  
      protected void installListeners() {
          titleChangeListener = new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent evt) {
                  if (evt.getPropertyName().equals("title")) {
                      caption.setText((String)evt.getNewValue());
                  } else if (evt.getPropertyName().equals("titleForeground")) {
                      caption.setForeground((Color)evt.getNewValue());
                  } else if (evt.getPropertyName().equals("titleFont")) {
                      caption.setFont((Font)evt.getNewValue());
                  } else if ("titleDarkBackground".equals(evt.getPropertyName())) {
                      topPanel.revalidateGradient();
                 
              } else if ("titleLightBackground".equals(evt.getPropertyName())) {
                  topPanel.revalidateGradient();
              }
              }
          };
          titledPanel.addPropertyChangeListener(titleChangeListener);
      }
  
      protected void uninstallListeners(JXTitledPanel panel) {
          titledPanel.removePropertyChangeListener(titleChangeListener);
      }
  
      protected void installProperty(JComponent c, String propName, Object value) {
          try {
              BeanInfo bi = Introspector.getBeanInfo(c.getClass());
              for(int i=0;i< bi.getPropertyDescriptors().length;i++) {
                  PropertyDescriptor pd=bi.getPropertyDescriptors()[i];
                  if (pd.getName().equals(propName)) {
                      Method m = pd.getReadMethod();
  