public static ActionListener cycleToProperty ( final String property , final PrefsConfig config , AbstractButton button , final int [ ] values ) { ActionListener al = new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { // get the current value and find out where it is in the list int oldval = config . getValue ( property , values [ 0 ] ) ; // if it's not even in the list, newidx will be 0 int newidx = ( 1 + IntListUtil . indexOf ( values , oldval ) ) % values . length ; config . setValue ( property , values [ newidx ] ) ; } } ; button . addActionListener ( al ) ; return al ; }
Configure the specified button to cause the specified property to cycle through the specified values whenever the button is pressed .