How to add JPanel to JLabel?
Hello sir:
I am not sure that Can we add JPanel to JLabel?
we know that we can we add JLabel to JPanel .
Is it logically correct or not?
I google a lot, cannot find this kind of example, I tried to do not success.
anybody can help give yes or no and explanation, if possible, example.
Thanks
# 1
You can, but why would you want to do this?A JLabel extends Container so you can add any component to it. By default a JLabel doesn't use a LayoutManager so you need to set the bounds of the component, or you need to set the LayoutManager.
# 2
Just for project, I have a project that has a main JPanel PanelMain , in this PanelMain , it has different components such as JLabel and JPanels jpa, jpb, etc on it,
I can make JLabel selectable, but I cannot make JPanels jpa, jpb etc selectable, How can I make JPanel jpa, jpb selectable like JLabels?
I cannot make JPanel jpa, jpb selectable, so I try to add JPanels to JLabel,
Can you help advice how to make jpa selectable or some good example?|
Thanks a lot