JavaSwingのGridBagLayoutに中央に配置された3つの垂直ボタンを追加しようとしています。現在、デフォルトのグリッドサイズは3x3だと思います。それを変更して列と行を追加できるかどうかを知りたかったのです。ペインに3つの中央に等間隔のボタンを作成したいだけです。
pane.setLayout(new GridLayout(10,1));
// Insert a space before the first button
for (int i = 1; i < 6; i++ ){
pane.add(new JLabel(""));
}
pane.add(new Button("1"));
pane.add(new Button("2"));
pane.add(new Button("3"));
// Insert a space after the last button
pane.add(new JLabel(""));
それが最終的な解決策でしたみんなありがとう!