Java Swing (BoxLayout) alignment issues

后端 未结 2 406
夕颜
夕颜 2021-01-22 11:33

I am extremely new to Java Swing, and I\'m having quite a bit of issues getting a nice layout going. I have checked out google, and even other answers on this website, but no in

2条回答
  •  终归单人心
    2021-01-22 12:10

    I would not recommend using setPreferredSize() AND setMaximumSize(). The latter will cause problems when stretching your main frame. [Your components will likely not want resize]

    You should be using layout managers to handle all the alignments itself. I would stay away from using BoxLayout in this case, as different components want to size differently, and that will sway the alignment when added into your BoxLayout panel.

    Moreover, you might want to give your main frame a layout as well. Can you post how you used your GridBagLayout?

提交回复
热议问题