public static synchronized void setToggling ( AbstractButton b ) { if ( _toggler == null ) { _toggler = new ActionListener ( ) { public void actionPerformed ( ActionEvent event ) { AbstractButton but = ( AbstractButton ) event . getSource ( ) ; but . setSelected ( ! but . isSelected ( ) ) ; } } ; } b . addActionListener ( _toggler ) ; }
Set the specified button such that it alternates between being selected and not whenever it is pushed .