Trying to create multiple JLabels, however only one is appearing

后端 未结 4 1210
时光说笑
时光说笑 2021-01-20 02:23

I am trying to create multiple JLabels of the same form and then trying to add them to the same JPanel. However, only one of the JLabels appears and I can\'t figure out why!

4条回答
  •  说谎
    说谎 (楼主)
    2021-01-20 02:49

    You aren't using the BorderLayout properly. The labels are all added at the center location of the layout, and thus overwrite each others. Try a FlowLayout instead, or even better, a MigLayout.

提交回复
热议问题