How to handle itemStateChanged properly

itemStateChanged is one of the common event in Swing framework. However, you might find that it usually fires out twice. The fact behind this behavior is there are 2 sub-events, says selected and unselected. Developer must deal with this property using getStateChange() method.

if (e.getStateChange()==.SELCTED) {
  //do your actions
}

Tags: ,

Reply