JLabel - get parent panel?

后端 未结 3 1238
情深已故
情深已故 2020-12-18 00:32

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 whic

3条回答
  •  伪装坚强ぢ
    2020-12-18 00:44

    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.

提交回复
热议问题