private void minimize ( ) { if ( timer != null ) { timer . stop ( ) ; timer = null ; } currentHeight = getHeight ( ) ; double steps = ( double ) durationMS / delayMS ; double delta = currentHeight - minimizedHeight ; final int stepSize = ( int ) Math . ceil ( delta / steps ) ; //System.out.println("steps " + steps); //System.out.println("currentHeight " + currentHeight); //System.out.println("delta " + delta); //System.out.println("stepSize " + stepSize); timer = new Timer ( delayMS , new ActionListener ( ) { @ Override public void actionPerformed ( ActionEvent e ) { currentHeight -= stepSize ; currentHeight = Math . max ( currentHeight , minimizedHeight ) ; if ( currentHeight <= minimizedHeight ) { minimized = true ; timer . stop ( ) ; timer = null ; } revalidate ( ) ; } } ) ; timer . setInitialDelay ( 0 ) ; timer . start ( ) ; }
Performs the minimization process