Hello Abhimanyus and welcome to the Ranch! For posting code here, please
UseCodeTags <- link which I've added for you this time.
Also, for getting better help on this or any other
Java forum, it would be good for you to learn and respect the
Java Coding Conventions, as that makes your code so much more readable for other coders. Variable names should start with a lowercase letter.
Read the API for ItemEvent. You'll find a method to determine whether the event corresponds to a selection or a deselection. Does that give you a clue why your program behaves the way it does?