Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

getting which of the JLabels get clicked?

 
Girish Vasmatkar
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello to all,

I have a org.jdesktop.swingx.JXTaskPane() component on my JFrame which comes as part of SwingX API. I have added many JLabels to this taskpane component and now i want to have information regarding which of the JLabels get clicked when i click one of them. Depending on which one of them get clicked i want to do different things. Just want to ask how to go about this? I tried each JLabel implement a MouseListener but i can't single one out from the list of JLabels.
 
Brian Cole
Author
Ranch Hand
Posts: 906
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Girish Vasmatkar:
I have added many JLabels to this taskpane component and now i want to have information regarding which of the JLabels get clicked when i click one of them. Depending on which one of them get clicked i want to do different things. Just want to ask how to go about this? I tried each JLabel implement a MouseListener but i can't single one out from the list of JLabels.


The I-want-a-label-that-acts-like-a-button topic comes up periodically.
The simple answer is to use an actual button and make it look like a label.

Take a look at some of the older threads, for instance this one.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic