Reputation: 5988
I am trying to register a click on a label, but i can't get it to work.
So far I've tried to set the SelectionAdapter
to the label but click-events aren't fired.
Upvotes: 4
Views: 4220
Reputation: 6069
For sake of completeness, I'll just add this code sample:
label.addMouseListener(new MouseAdapter() {
@Override
public void mouseUp(MouseEvent event) {
super.mouseUp(event);
if (event.getSource() instanceof Label) {
Label label = (Label)event.getSource();
System.out.println("Label was clicked: " + label.getText());
}
}
});
Upvotes: 5
Reputation: 3226
Labels are not selectable Controls SelectionAdapter won't work for it. Try adding a MouseListener.
Upvotes: 6