{
// Transition panel
final ComponentTransition componentTransition = new ComponentTransition ();
// Transition effect
final CurtainTransitionEffect effect = new CurtainTransitionEffect ();
effect.setType ( CurtainType.fade );
effect.setSize ( 10 );
effect.setSpeed ( 2 );
componentTransition.setTransitionEffect ( effect );
// Toolbar #1
final WebToolBar toolBar1 = new WebToolBar ( WebToolBar.HORIZONTAL );
toolBar1.setFloatable ( false );
toolBar1.add ( WebButton.createIconWebButton ( loadIcon ( "toolbar/1.png" ), true ) );
toolBar1.addSeparator ();
toolBar1.add ( WebButton.createIconWebButton ( loadIcon ( "toolbar/2.png" ), true ) );
toolBar1.addSeparator ();
toolBar1.add ( WebButton.createIconWebButton ( loadIcon ( "toolbar/3.png" ), true ) );
toolBar1.addToEnd ( WebButton.createIconWebButton ( loadIcon ( "toolbar/4.png" ), true ) );
// Toolbar #2
final WebToolBar toolBar2 = new WebToolBar ( WebToolBar.HORIZONTAL );
toolBar2.setFloatable ( false );
toolBar2.addSpacing ();
toolBar2.add ( new WebLabel ( "Curtain transition example" ) );
toolBar2.addSpacing ();
componentTransition.setContent ( toolBar2 );
// Initial transition panel state
componentTransition.setContent ( toolBar1 );
componentTransition.setPreferredSize ( SwingUtils.max ( toolBar1, toolBar2 ) );
// States switch button
final WebButton switchView = new WebButton ( loadIcon ( "switch.png" ) );
switchView.setDrawFocus ( false );
switchView.addActionListener ( new ActionListener ()
{
@Override
public void actionPerformed ( ActionEvent e )
{
if ( componentTransition.getContent () == toolBar1 )
{
effect.setDirection ( Direction.right );
componentTransition.performTransition ( toolBar2 );
}
else
{
effect.setDirection ( Direction.left );
componentTransition.performTransition ( toolBar1 );
}
}
} );
componentTransition.addTransitionListener ( new TransitionListener ()