Red de conocimiento del abogados - Ley de patentes - ¿Cómo hacer que la última celda abarque dos filas en el diseño GridBagLayout en Java swing?

¿Cómo hacer que la última celda abarque dos filas en el diseño GridBagLayout en Java swing?

El programa Java para hacer que la última celda abarque dos filas en el diseño GridBagLayout es el siguiente:

prueba de paquete;

import java.awt.GridBagConstraints;

importar java.awt.GridBagLayout;

importar javax.swing.JButton;

importar javax.swing.JFrame;

público clase TestGridBagLayout {

public static void main(String[] args) {

JFrame jf = nuevo JFrame();

GridBagLayout gbl = nuevo GridBagLayout() ;

p>

GridBagConstraints gbc = new GridBagConstraints();

jf.setLayout(gbl);

JButton jb1 = new JButton("BUTTON1 ");

gbc.fill = GridBagConstraints.BOTH;

gbc.gridx = 0;

gbc.gridy = 0;

gbc.weightx = 10;

gbc.weighty = 10;

gbl.setConstraints(jb1, gbc);

jf.add(jb1);

JButton jb2 = new JButton("BUTTON2");

GridBagConstraints gbc1 = nuevo GridBagConstraints();

gbc1.fill = GridBagConstraints.BOTH;

gbc1.gridx = 1;

gbc1.gridy = 0;

gbc1.gridheight = 2;

gbc1.weightx = 20;

gbc1 .weighty = 20;

gbl.setConstraints(jb2, gbc1);

jf.add(jb2);

JButton jb3 = nuevo JButton("BUTTON3 ");

GridBagConstraints gbc2 = nuevo GridBagConstraints();

gbc2.fill = GridBagConstraints.BOTH;

gbc2. gridx = 0;

gbc2.gridy = 1;

gbc2.gridwidth = 1;

gbc2.weightx = 10;

gbc2.weighty = 10;

p>

gbl.setConstraints(jb3, gbc2);

jf.add(jb3);

jf.setDefaultCloseOperation(JFrame .EXIT_ON_CLOSE);

jf.setSize(500, 400);

jf.setVisible(true);

}

}