Laf-Widget - documentation
Author: laf-widget.dev.java.net
Description: Laf-Widget
Keywords: java, look, feel, skins, plaf, swing, ui, pluggable, widget

# Laf-Widget client properties

View all client properties.

Client property name | LafWidget.ANIMATION_KIND
Description | Client property name for specifying the kind of animation on various components. The value should be one of `LafConstants.AnimationKind` enum. This property can be set either on component or globally on `UIManager`. In order to compute the animation kind for some component, the component's hierarchy is traversed bottom up. The first component that has this property set, defines the animation kind. Finally, if neither component not its ancestors define this property, the global setting on `UIManager` is checked. If there is no global setting, the default `LafConstants.AnimationKind.REGULAR` is taken.
See also |
Sample code | `import java.awt.*; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.*; import org.jvnet.lafwidget.LafWidget; import org.jvnet.lafwidget.LafWidgetUtilities; import org.jvnet.lafwidget.utils.LafConstants.AnimationKind; import org.jvnet.substance.SubstanceDefaultListCellRenderer; import org.jvnet.substance.SubstanceLookAndFeel; /** * Test application that shows the use of the {@link LafWidget#ANIMATION_KIND} * client property. * * @author Kirill Grouchnikov * @see LafWidget#ANIMATION_KIND */ public class AnimationKindProperty extends JFrame { /** * Creates the main frame for <code>this</code> sample. */ public AnimationKindProperty() { super("Animation kind"); this.setLayout(new BorderLayout()); final JButton button1 = new JButton("button"); JPanel main = new JPanel(new FlowLayout(FlowLayout.CENTER)); this.add(main, BorderLayout.CENTER); main.add(button1); JPanel controls = new JPanel(new FlowLayout(FlowLayout.RIGHT)); final JComboBox animationKindCombo = new JComboBox(new Object[] { AnimationKind.NONE, AnimationKind.FAST, AnimationKind.REGULAR, AnimationKind.SLOW, AnimationKind.DEBUG_FAST, AnimationKind.DEBUG, AnimationKind.DEBUG_SLOW }); animationKindCombo.setRenderer(new SubstanceDefaultListCellRenderer() { @Override public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { AnimationKind kind = (AnimationKind) value; return super.getListCellRendererComponent(list, kind.getName(), index, isSelected, cellHasFocus); } }); animationKindCombo.setSelectedItem(LafWidgetUtilities .getAnimationKind(button1)); animationKindCombo.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { button1.putClientProperty(LafWidget.ANIMATION_KIND, animationKindCombo.getSelectedItem()); button1.requestFocus(); } }); controls.add(new JLabel("Animation kind")); controls.add(animationKindCombo); this.add(controls, BorderLayout.SOUTH); this.setSize(400, 200); 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[] args) throws Exception { UIManager.setLookAndFeel(new SubstanceLookAndFeel()); JFrame.setDefaultLookAndFeelDecorated(true); SwingUtilities.invokeLater(new Runnable() { public void run() { new AnimationKindProperty().setVisible(true); } }); } }` The screenshot below shows a button in fade-in animation sequence (mouse is hovering over the button) after this API has been called with `LafConstants.AnimationKind.DEBUG` value. Note the fade from grey to aqua theme: