Not able to add 3 JPanels to a main panel

前端 未结 4 762
北荒
北荒 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:17

    You might consider using a MigLayout instead, the code is much simpler:

    panel1Customizer();
    panel2customizer();
    panel3Customizer();
    setLayout(new MigLayout("fill, wrap 3"));
    
    add(panel1, "grow");
    add(panel2, "grow");
    add(panel3, "grow");
    

提交回复
热议问题