Placing a JLabel at a specific x,y coordinate on a JPanel

前端 未结 6 669
梦毁少年i
梦毁少年i 2020-12-05 16:12

I\'m trying to place a series of JLabels at specific X and Y coordinates on a JPanel (and set its height and width, too). No matter what I do, each label winds up immediatel

6条回答
  •  渐次进展
    2020-12-05 16:37

    You have to set your container's Layout to null:

    myPanel.setLayout(null);
    

    However is a good advise also to take a look at the Matisse Layout Manager, I guess it is called GroupLayout now. The main problem with absolute positioning is what happens when the window changes its size.

提交回复
热议问题