| |
14. 94. 8. Place a component at (0,1) with a column weight 1 and a row weight of 2 |
|
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import javax.swing.JFrame;
public class Main {
public static void main(String[] argv) throws Exception {
JFrame frame = new JFrame();
GridBagLayout gbl = new GridBagLayout();
frame.setLayout(gbl);
JButton component = new JButton("1");
frame.add(component);
frame.add(new JButton("2"));
gbl.layoutContainer(frame);
GridBagConstraints gbc = new GridBagConstraints();
gbc.gridx = 0;
gbc.gridy = 1;
gbc.weightx = 1;
gbc.weighty = 2;
gbl.setConstraints(component, gbc);
frame.pack();
frame.setVisible(true);
}
}
|
|
|