public void stateChanged ( ChangeEvent e ) { SpinnerNumberModel model = ( SpinnerNumberModel ) ( ( JSpinner ) e . getSource ( ) ) . getModel ( ) ; int value = model . getNumber ( ) . intValue ( ) ; boolean increase = ( value > oldSpinnerValue ) ? true : false ; oldSpinnerValue = value ; int month = getMonth ( ) ; if ( increase ) { month += 1 ; if ( month == 12 ) { month = 0 ; if ( yearChooser != null ) { int year = yearChooser . getYear ( ) ; year += 1 ; yearChooser . setYear ( year ) ; } } } else { month -= 1 ; if ( month == - 1 ) { month = 11 ; if ( yearChooser != null ) { int year = yearChooser . getYear ( ) ; year -= 1 ; yearChooser . setYear ( year ) ; } } } setMonth ( month ) ; }
Is invoked if the state of the spnner changes .