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

前端 未结 6 670
梦毁少年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:23

    Layout managers are used to automatically determine the layout of components in a container. If you want to put components at specific coordinate locations, then you should not use a layout manager at all.

    myPanel = new JPanel(null);
    

    or

    myPanel.setLayout(null);
    

提交回复
热议问题