Alignment issue in GridBagLayout

廉价感情. 提交于 2019-12-01 23:57:48

Since each panel is being centered horizontally, they will not align unless they have the same width. It would be easier to put them in a common panel and share a GridBagLayout.

You could change the top level layout to left-align your components (e.g. in another GridBagLayout with WEST/LEFT anchors).

Side note: Those negative insets are going to get you into trouble. Side note2: instead of setting gridx and gridy manually, look into REMAINDER Side note 3: most of your gbc are indentical. reuse them.

this.setLayout(new GridBagLayout());
this.add(createLeftPanel(), gbc);
...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!