All pastes #342122 Raw Edit

Plouj

public text v1 · immutable
·published 2007-02-06 02:56 UTC
rendered paste body
        private JPanel setupElementsPane() {
                JPanel currentPane = new JPanel();

                currentPane.setBorder(BorderFactory.createTitledBorder(elementsPaneTitle));
                currentPane.setLayout(new GridBagLayout());

                // the gridbag constraints instance
                GridBagConstraints c = new GridBagConstraints();
                c.anchor = GridBagConstraints.FIRST_LINE_START;

                addElementButton = new JButton(addButtonStr);
                removeElementButton = new JButton(removeButtonStr);

                c.gridx=1;
                c.gridy=0;
                currentPane.add(addElementButton, c);

                c.gridx=2;
                c.gridy=0;
                currentPane.add(removeElementButton, c);

                tableScroller = setupElementsTable();

                c.gridx=1;
                c.gridy=1;
                c.weightx=1.0;
                c.weighty=1.0;
                c.fill=GridBagConstraints.BOTH;
                c.gridwidth=GridBagConstraints.REMAINDER;
                currentPane.add(tableScroller, c);
                c.weightx=0.0;
                c.weighty=0.0;
                c.gridwidth=1;
                c.fill=GridBagConstraints.NONE;

                // up/down buttons
                upElementButton = new BasicArrowButton(SwingConstants.NORTH);
                downElementButton = new BasicArrowButton(SwingConstants.SOUTH);
                c.gridx=1;
                c.gridy=2;
                currentPane.add(upElementButton, c);

                c.gridx=2;
                c.gridy=2;
                currentPane.add(downElementButton, c);

                // using a formatted text field rather than a label makes this text
                // good for copying with the mouse
                totalCostField = new JFormattedTextField(totalCostFormat);
                // set to a temporary value
                totalCostField.setValue(1234560.993); // TODO make this automatically calculated!
                totalCostField.setColumns(10);
                totalCostField.addPropertyChangeListener("value", this);
                totalCostField.setEditable(false); // make it uneditable

                c.gridx=3;
                c.gridy=2;
                currentPane.add(new JLabel(totalLabel), c);

                c.gridx=4;
                c.gridy=2;
                c.weighty=1.0;
                c.fill=GridBagConstraints.HORIZONTAL;
                c.gridwidth=GridBagConstraints.REMAINDER;
                currentPane.add(totalCostField, c);

                return currentPane;
        }