Substance client properties

View all API methods.

View all client properties.


Client property name

SubstanceLookAndFeel.TABBED_PANE_TAB_ANIMATION_KIND

Description

Client property name for specifying the animation kind of the icon of a single tab in tabbed pane. This property can be set on per-tab basis (on the JComponent in a JTabbedPane). The value should be one of SubstanceConstants.TabAnimationKind enum. Setting the value of this property to null stops the tab animation.


See also


Sample code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.*;

import org.jvnet.substance.SubstanceLookAndFeel;
import org.jvnet.substance.button.ClassicButtonShaper;
import org.jvnet.substance.utils.SubstanceConstants.TabAnimationKind;

import test.Check;

/**
 * Test application that shows the use of the
 {@link SubstanceLookAndFeel#TABBED_PANE_TAB_ANIMATION_KIND} client property.
 
 @author Kirill Grouchnikov
 @see SubstanceLookAndFeel#TABBED_PANE_TAB_ANIMATION_KIND
 */
public class TabbedPaneTabAnimation extends JFrame {
  /**
   * Creates the main frame for <code>this</code> sample.
   */
  public TabbedPaneTabAnimation() {
    super("Tabbed pane tab animation");

    this.setLayout(new BorderLayout());

    // create tabbed pane with a few tabs
    final JTabbedPane jtp = new JTabbedPane();
    jtp.addTab("First", Check.getIcon("flag_mexico")new JPanel());
    jtp.addTab("Second", Check.getIcon("flag_sweden")new JPanel());

    this.add(jtp, BorderLayout.CENTER);

    JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    final JComboBox animationKindCombo = new JComboBox(new Object[] {
        "stop""load""error""warning" });
    JButton setAnimationKindButton = new JButton("Set");
    setAnimationKindButton.putClientProperty(
        SubstanceLookAndFeel.BUTTON_SHAPER_PROPERTY,
        new ClassicButtonShaper());
    setAnimationKindButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Component comp = jtp.getComponentAt(1);
        String selectedAnimationKind = (StringanimationKindCombo
            .getSelectedItem();
        TabAnimationKind animKind = null;

        // compute the new animation kind to set on the second tab
        // component
        if ("load".equals(selectedAnimationKind))
          animKind = TabAnimationKind.LOADING;
        if ("error".equals(selectedAnimationKind))
          animKind = TabAnimationKind.ERROR;
        if ("warning".equals(selectedAnimationKind))
          animKind = TabAnimationKind.WARNING;
        if ((comp != null&& (comp instanceof JComponent)) {
          JComponent jc = (JComponentcomp;
          // set the selected animation kind
          jc
              .putClientProperty(
                  SubstanceLookAndFeel.TABBED_PANE_TAB_ANIMATION_KIND,
                  animKind);
        }

      }
    });

    controls.add(animationKindCombo);
    controls.add(setAnimationKindButton);
    this.add(controls, BorderLayout.SOUTH);

    this.setSize(400200);
    this.setLocationRelativeTo(null);
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  }

  /**
   * The main method for <code>this</code> sample. The arguments are
   * ignored.
   
   @param args
   *            Ignored.
   @throws Exception
   *             If some exception occured. Note that there is no special
   *             treatment of exception conditions in <code>this</code>
   *             sample code.
   */
  public static void main(String[] argsthrows Exception {
    UIManager.setLookAndFeel(new SubstanceLookAndFeel());
    JFrame.setDefaultLookAndFeelDecorated(true);
    SwingUtilities.invokeLater(new Runnable() {
      public void run() {
        new TabbedPaneTabAnimation().setVisible(true);
      }
    });
  }
}

The screenshot below shows tabbed pane with default icons - this propetry is not installed:

The screenshot below shows tabbed pane with SubstanceConstants.TabAnimationKind.WARNING installed on the second tab (one of the animation cycles is shown):