1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| public class AllPanel extends JPanel {
public AllPanel () {
super(new GridBagLayout());
onePanel = new MyPanel("one label:", 0.d);
twoPanel = new MyPanel("two label:", 0.d);
threePanel = new MyPanel("three label:", 0.d);
fourPanel = new MyPanel("four label:", 0.d);
fivePanel = new MyPanel("five label:", 0.d);
sixPanel = new MyPanel("six label:", 0.d);
init();
}
private void init() {
JPanel leftPanel = new JPanel(new GridBagLayout());
JLabel label = new JLabel("left panel");
leftPanel.add(label, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
leftPanel.add(onePanel , new GridBagConstraints(0, 1, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
leftPanel.add(twoPanel , new GridBagConstraints(0, 2, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
leftPanel.add(threePanel , new GridBagConstraints(0, 3, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
JPanel rightPanel = new JPanel(new GridBagLayout());
postProcPanel.add(new JLabel("right panel"), new GridBagConstraints(0, 0, 1, 1, 0.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
new Insets(5, 5, 5, 5), 0, 0));
rightPanel.add(fourPanel , new GridBagConstraints(0, 1, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
rightPanel.add(fivePanel , new GridBagConstraints(0, 2, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
rightPanel.add(sixPanel, new GridBagConstraints(0, 3, 1, 1, 1.0D, 0.0D, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 0, 5, 0), 0, 0));
add(leftPanel , new GridBagConstraints(0, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 20, 0, 5), 0, 0));
add(rightPanel , new GridBagConstraints(1, 0, 1, 1, 1.0, 1.0, GridBagConstraints.WEST, GridBagConstraints.BOTH, new Insets(0, 30, 0, 5), 0, 0));
} |
Partager