aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes getting which of the JLabels get clicked? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "getting which of the JLabels get clicked?" Watch "getting which of the JLabels get clicked?" New topic
Author

getting which of the JLabels get clicked?

Girish Vasmatkar
Ranch Hand

Joined: Apr 24, 2008
Posts: 201
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

Joined: Sep 20, 2005
Posts: 862
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.


bitguru blog
 
Consider Paul's rocket mass heater.
 
subject: getting which of the JLabels get clicked?