private void zInstallSpinnerButtonListener ( Component spinnerButton ) { spinnerButton . addMouseListener ( new MouseAdapter ( ) { /** * mouseReleased, This will be called when the spinner button is pressed down. This is * only called once before release no matter how long the mouse button is held down. */ @ Override public void mousePressed ( MouseEvent event ) { if ( ! isEnabled ( ) ) { return ; } if ( getTime ( ) == null ) { setTime ( LocalTime . NOON ) ; } if ( event . getSource ( ) == getComponentDecreaseSpinnerButton ( ) ) { setTime ( getTime ( ) . plusMinutes ( - 1 ) ) ; decreaseTimer . start ( ) ; } else { setTime ( getTime ( ) . plusMinutes ( 1 ) ) ; increaseTimer . start ( ) ; } } /** * mouseReleased, This will be called when the spinner button is released. */ @ Override public void mouseReleased ( MouseEvent event ) { if ( event . getSource ( ) == getComponentDecreaseSpinnerButton ( ) ) { decreaseTimer . stop ( ) ; } else { increaseTimer . stop ( ) ; } } } ) ; }
zInstallSpinnerButtonListener This installs the mouse listeners on the spinner buttons . These most listeners will listen for mouse pressed and mouse released the events to start and stop the spinner timers . The spinner timers will increase or decrease the time contained in this time picker at a rate that accelerates over a set range of time .