// Base content pane
final WebPanel contentPane = new WebPanel ();
// Exampler loading dialog
final WebProgressDialog progress = createProgressDialog ();
progress.addWindowListener ( new WindowAdapter ()
{
@Override
public void windowClosed ( final WindowEvent e )
{
// Stop loading demo on dialog close
System.exit ( 0 );
}
} );
progress.setVisible ( true );
// Loading default demo dialog settings
progress.setText ( "Configuring demo..." );
setTitle ( getDemoTitle () );
setIconImages ( WebLookAndFeel.getImages () );
setLayout ( new BorderLayout () );
HotkeyManager.installShowAllHotkeysAction ( getRootPane (), Hotkey.F1 );
// Creating main content
exampleTabs = ExamplesManager.createExampleTabs ( WebLookAndFeelDemo.this, progress );
// Jar class structure creation
sourceViewer = new SourceViewer ( ExamplesManager.createJarStructure ( progress ) );
// Content
containerTransition = new ComponentTransition ( exampleTabs );
containerTransition.setTransitionEffect ( new FadeTransitionEffect () );
containerTransition.addTransitionListener ( new TransitionAdapter ()
{
@Override
public void transitionFinished ()
{
// To show back tooltip once
if ( !isSourceTipShownOnce () && containerTransition.getContent () == sourceViewer )
{
// Marking the fact we already seen this tip
setSourceTipShownOnce ();
// Showing helpful tip
TooltipManager.showOneTimeTooltip ( locationBreadcrumb.getComponent ( 0 ), null, infoIcon,
"You can go back to demos at anytime " + "using this breadcrumb", TooltipWay.up );
}
}
} );
contentPane.add ( containerTransition, BorderLayout.CENTER );
// Status bar
contentPane.add ( createStatusBar (), BorderLayout.SOUTH );
exampleTabs.setSelectedIndex ( 0 );
// Base content
appearanceTransition = new ComponentTransition ( createBackgroundPanel () )
{
@Override
public Dimension getPreferredSize ()
{
return contentPane.getPreferredSize ();
}
};
final CurtainTransitionEffect effect = new CurtainTransitionEffect ();
effect.setDirection ( Direction.down );
effect.setType ( CurtainType.fade );
appearanceTransition.setTransitionEffect ( effect );
appearanceTransition.addAncestorListener ( new AncestorAdapter ()
{
@Override
public void ancestorAdded ( final AncestorEvent event )
{
appearanceTransition.delayTransition ( 1000, contentPane );
}
} );
appearanceTransition.addTransitionListener ( new TransitionAdapter ()
{
@Override
public void transitionFinished ()
{
// Search tip
if ( !isSearchTipShownOnce () )
{
setSearchTipShownOnce ();
final JRootPane rootPane = WebLookAndFeelDemo.this.getRootPane ();
final WebCustomTooltip searchTip = TooltipManager
.showOneTimeTooltip ( rootPane, new Point ( rootPane.getWidth () / 2, 0 ), SlidingSearch.searchIcon,
"You can quickly navigate through components using search (Ctrl+F)", TooltipWay.down );
final HotkeyInfo searchTipHide = HotkeyManager.registerHotkey ( Hotkey.CTRL_F, new HotkeyRunnable ()
{
@Override
public void run ( final KeyEvent e )
{
searchTip.closeTooltip ();
}
} );
searchTip.addTooltipListener ( new TooltipAdapter ()
{
@Override
public void tooltipDestroyed ()
{
HotkeyManager.unregisterHotkey ( searchTipHide );
}
} );
}
}
} );
add ( appearanceTransition, BorderLayout.CENTER );
// Search
installSearch ();
// Finishing load text
progress.setText ( "Starting demo..." );
// Creating a small delay to not blink with windows too fast
ThreadUtils.sleepSafely ( 500 );
// Configuring demo window
pack ();
setLocationRelativeTo ( null );
setDefaultCloseOperation ( JFrame.EXIT_ON_CLOSE );
// Displaying demo
progress.setVisible ( false );
}