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


Win a copy of Java 8 in Action this week in the Java 8 forum!
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: 199
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: getting which of the JLabels get clicked?
 
Similar Threads
Getting mouse events for a component in a Jtable cell
Adding Hyperlink To JLabel
I need assistance
Problem printing JPanel in JTable
JLabel - Receiving Focus