Alex Rivera | Logout

JLabel - get parent panel?

Asked 2009-12-21T07:57:38.980
11

Is it possible to get the name of the panel that a JLabel is added to? I added some JLabels to different JPanels, and I want to call different mouse events according to which panel the jLabels are placed upon.

Edit
Report

1 Answer

13

If you run label.getParent() it will return the panel the label is inside.

You could then call parent.getName() but the fact the you will now have the object you might not need this now.

answered 2009-12-21T08:03:46.533

Your Answer