Choose swing components selectively?

I was just starting to learn swing and could not find any clear instructions for this: I would like to have a JLabel (which contains a background image) and, pushed on top of it, two (or maybe more) JButtons, If I use the OverlayLayout layout manager, the buttons displayed on top of each other.

What would be the best way to correctly display buttons on top of a label?

+3
source share
3 answers
  • Create a JPanel that contains its own layout manager (e.g. GridLayout)
  • Set JPanel size (Assuming OverlayLayout is not a reasonable size)
  • Add JButtons to this panel
  • Add this panel to JLabel w / bgimage
+2
source
0

. . .

0
source

Source: https://habr.com/ru/post/1785048/


All Articles