Here you can find the source of setSelectedSilently(AbstractButton x, boolean b)
public static void setSelectedSilently(AbstractButton x, boolean b)
//package com.java2s; //License from project: LGPL import java.awt.event.ActionListener; import java.awt.event.ItemListener; import javax.swing.AbstractButton; public class Main { public static void setSelectedSilently(AbstractButton x, boolean b) { ActionListener[] al = x.getActionListeners(); if (al != null && al.length > 0) { for (ActionListener a : al) x.removeActionListener(a); }/*from w w w . ja va2 s . c o m*/ ItemListener[] il = x.getItemListeners(); if (il != null && il.length > 0) { for (ItemListener a : il) x.removeItemListener(a); } x.setSelected(b); if (al != null && al.length > 0) { for (ActionListener a : al) x.addActionListener(a); } if (il != null && il.length > 0) { for (ItemListener a : il) x.addItemListener(a); } } }