Here you can find the source of setToggling(AbstractButton b)
public static synchronized void setToggling(AbstractButton b)
//package com.java2s; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import javax.swing.AbstractButton; public class Main { /** Our lazily-initialized toggling action listener. */ protected static ActionListener _toggler; /**// ww w .j a v a 2s . com * Set the specified button such that it alternates between being selected and not whenever it * is pushed. */ 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); } }