Not able to add 3 JPanels to a main panel

前端 未结 4 760
北荒
北荒 2021-01-24 15:09

I have 3 JPanels and I want to place them all in one JPanel. I used the GridBagLayout for the main panel. But only one panel is getting added. Why might this be?



        
4条回答
  •  执笔经年
    2021-01-24 15:29

    I am not sure but I think you need to add a GridBagConstraints to your GridBagLayout. Try look at this site to get the idea on how to work with GridBagLayout: link

    Or maybe just use another Layout for your JFrame, maybe BorderLayout or GridLayout to arrange your Panels correctly

提交回复
热议问题