Example usage for java.awt GridBagConstraints RELATIVE

List of usage examples for java.awt GridBagConstraints RELATIVE

Introduction

In this page you can find the example usage for java.awt GridBagConstraints RELATIVE.

Prototype

int RELATIVE

To view the source code for java.awt GridBagConstraints RELATIVE.

Click Source Link

Document

Specifies that this component is the next-to-last component in its column or row ( gridwidth , gridheight ), or that this component be placed next to the previously added component ( gridx , gridy ).

Usage

From source file:com.db4o.sync4o.ui.Db4oSyncSourceConfigPanel.java

private void setupControls() {

    // Layout and setup UI components...

    setLayout(new BoxLayout(this, BoxLayout.PAGE_AXIS));
    add(_namePanel);//from ww w . java 2 s . co  m
    _namePanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(_fieldsPanel);
    _fieldsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
    add(_classConfigsTree);
    _classConfigsTree.setAlignmentX(Component.LEFT_ALIGNMENT);
    _classConfigsTree.setPreferredSize(new Dimension(300, 300));
    add(_buttonsPanel);
    _buttonsPanel.setAlignmentX(Component.LEFT_ALIGNMENT);

    JLabel l;

    // Admin UI Management Panels use a title
    // (in a particular "title font") to identify themselves
    l = new JLabel("Edit Db4oSyncSource Configuration", SwingConstants.CENTER);
    l.setBorder(new TitledBorder(""));
    l.setFont(titlePanelFont);
    _namePanel.add(l);

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.gridwidth = 1;
    labelConstraints.fill = GridBagConstraints.NONE;
    labelConstraints.weightx = 0.0;
    labelConstraints.gridx = 0;
    labelConstraints.gridy = 0;
    labelConstraints.anchor = GridBagConstraints.EAST;

    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.gridwidth = 2;
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridx = 1;
    fieldConstraints.gridy = 0;

    _fieldsPanel.add(new JLabel("Source URI: "), labelConstraints);
    _fieldsPanel.add(_sourceUriValue, fieldConstraints);

    labelConstraints.gridy = GridBagConstraints.RELATIVE;
    fieldConstraints.gridy = GridBagConstraints.RELATIVE;

    _fieldsPanel.add(new JLabel("Name: "), labelConstraints);
    _fieldsPanel.add(_nameValue, fieldConstraints);

    fieldConstraints.gridwidth = 1;

    _fieldsPanel.add(new JLabel("db4o File: "), labelConstraints);
    _fieldsPanel.add(_dbFileValue, fieldConstraints);

    _dbFileValue.setEditable(false);

    fieldConstraints.gridwidth = 2;

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.gridwidth = 1;
    buttonConstraints.fill = GridBagConstraints.NONE;
    buttonConstraints.gridx = 2;
    buttonConstraints.gridy = 3;
    _dbFileLocateButton.setText("...");
    _fieldsPanel.add(_dbFileLocateButton, buttonConstraints);

    buttonConstraints.gridwidth = 3;
    buttonConstraints.fill = GridBagConstraints.NONE;
    buttonConstraints.gridx = 0;
    buttonConstraints.gridy = GridBagConstraints.RELATIVE;
    buttonConstraints.anchor = GridBagConstraints.CENTER;

    // Ensure all the controls use the Admin UI standard font
    Component[] components = _fieldsPanel.getComponents();
    for (int i = 0; i < components.length; i++) {

        Component c = components[i];
        c.setFont(defaultFont);

    }

    _confirmButton.setText("Add");
    _buttonsPanel.add(_confirmButton);

}

From source file:savant.util.swing.TrackChooser.java

private void initLayout() {

    this.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    //FILLER//  w  ww . j a  v a  2 s .  c o  m
    //LEFT LABEL
    JLabel leftLabel = new JLabel("All Tracks");
    leftLabel.setFont(new Font(null, Font.BOLD, 12));
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(5, 5, 5, 5);
    add(leftLabel, c);

    // RIGHT LABEL
    JLabel rightLabel = new JLabel("Selected Tracks");
    rightLabel.setFont(new Font(null, Font.BOLD, 12));
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(rightLabel, c);

    //LEFT LIST
    leftList = new JList();
    JScrollPane leftScroll = new JScrollPane();
    leftScroll.setViewportView(leftList);
    leftScroll.setMinimumSize(new Dimension(450, 300));
    leftScroll.setPreferredSize(new Dimension(450, 300));
    c.weightx = 1.0;
    c.weighty = 1.0;
    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 4;
    add(leftScroll, c);

    //RIGHT LIST
    rightList = new JList();
    JScrollPane rightScroll = new JScrollPane();
    rightScroll.setViewportView(rightList);
    rightScroll.setMinimumSize(new Dimension(450, 300));
    rightScroll.setPreferredSize(new Dimension(450, 300));
    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(rightScroll, c);

    // MOVE RIGHT
    c.weightx = 0.0;
    c.weighty = 0.5;
    c.gridx = 1;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    add(createMoveRight(), c);

    // MOVE LEFT
    c.gridy = 2;
    add(createMoveLeft(), c);

    // ALL RIGHT
    c.gridy = 3;
    add(createAllRight(), c);

    //ALL LEFT
    c.gridy = 4;
    this.add(createAllLeft(), c);

    //FILTER
    c.gridx = 0;
    c.gridy = 5;
    add(createFilterPanel(), c);

    //AUTO SELECT ALL
    c.gridx = 2;
    add(createSelectAllCheck(), c);

    //SEPARATOR
    JSeparator separator1 = new JSeparator(SwingConstants.HORIZONTAL);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy = GridBagConstraints.RELATIVE;
    c.weightx = 1.0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    add(separator1, c);

    if (selectBase) {

        //SELECT BASE PANEL
        JPanel selectBasePanel = new JPanel(new BorderLayout());
        c.gridwidth = 2;
        add(selectBasePanel, c);

        //SELECT BASE LABEL
        JLabel selectBaseLabel = new JLabel("(Optional) Select Base: ");
        selectBasePanel.add(selectBaseLabel, BorderLayout.WEST);

        //SELECT BASE FIELD
        selectBaseField = new JTextField();
        selectBasePanel.add(selectBaseField, BorderLayout.CENTER);

        //SELECT BASE EXAMPLE
        JLabel selectBaseExample = new JLabel("  ex. 123,456,789");
        selectBasePanel.add(selectBaseExample, BorderLayout.EAST);

        //SEPARATOR
        JSeparator separator2 = new JSeparator(SwingConstants.HORIZONTAL);
        c.gridwidth = GridBagConstraints.REMAINDER;
        add(separator2, c);
    }

    JPanel okCancelPanel = new JPanel(new BorderLayout());
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;
    c.fill = GridBagConstraints.NONE;
    add(okCancelPanel, c);

    //OK
    okCancelPanel.add(createOKButton(), BorderLayout.CENTER);

    //CANCEL
    okCancelPanel.add(createCancelButton(), BorderLayout.EAST);

    pack();
}

From source file:org.openconcerto.erp.core.supplychain.receipt.component.BonReceptionSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Champ Module
    c.gridx = 0;/*from ww  w . ja  v  a2 s . c o m*/
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();
    this.setAdditionalFieldsPanel(new FormLayouter(addP, 1));
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.textTotalHT.setOpaque(false);
    this.textTotalTVA.setOpaque(false);
    this.textTotalTTC.setOpaque(false);

    this.selectCommande = new ElementComboBox();
    // Numero
    JLabel labelNum = new JLabel(getLabelFor("NUMERO"));
    labelNum.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNum, c);

    this.textNumeroUnique = new JUniqueTextField(16);
    c.gridx++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    DefaultGridBagConstraints.lockMinimumSize(this.textNumeroUnique);
    this.add(this.textNumeroUnique, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx++;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate date = new JDate(true);
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(date, c);
    // Reference
    c.gridy++;
    c.gridx = 0;
    final JLabel labelNom = new JLabel(getLabelFor("NOM"));
    labelNom.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(labelNom, c);
    c.gridx++;
    c.fill = GridBagConstraints.HORIZONTAL;
    DefaultGridBagConstraints.lockMinimumSize(this.textReference);
    this.add(this.textReference, c);
    // Fournisseur
    JLabel labelFournisseur = new JLabel(getLabelFor("ID_FOURNISSEUR"));
    labelFournisseur.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.weighty = 0;
    this.add(labelFournisseur, c);

    this.fournisseur = new ElementComboBox();
    c.gridx++;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.fournisseur, c);

    // Devise
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_DEVISE"), SwingConstants.RIGHT), c);

    final ElementComboBox boxDevise = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(boxDevise, c);
    this.addView(boxDevise, "ID_DEVISE");

    // Element du bon
    this.tableBonItem = new BonReceptionItemTable();
    c.gridx = 0;
    c.gridy++;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.tableBonItem, c);
    this.fournisseur.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            tableBonItem.setFournisseur(fournisseur.getSelectedRow());
        }
    });

    c.anchor = GridBagConstraints.EAST;
    // Totaux
    reconfigure(this.textTotalHT);
    reconfigure(this.textTotalTVA);
    reconfigure(this.textTotalTTC);

    // Poids Total
    c.gridy++;
    c.gridx = 1;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    if (b) {
        JPanel panelPoids = new JPanel(new GridBagLayout());
        GridBagConstraints c2 = new DefaultGridBagConstraints();
        c2.fill = GridBagConstraints.NONE;

        panelPoids.add(new JLabel(getLabelFor("TOTAL_POIDS")), c2);
        // Necessaire pour ne pas avoir de saut de layout
        DefaultGridBagConstraints.lockMinimumSize(this.textPoidsTotal);
        this.textPoidsTotal.setEnabled(false);
        this.textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        this.textPoidsTotal.setDisabledTextColor(Color.BLACK);
        c2.gridx++;
        c2.weightx = 1;
        c2.fill = GridBagConstraints.HORIZONTAL;
        panelPoids.add(this.textPoidsTotal, c2);
        this.add(panelPoids, c);

    }

    c.gridx = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    final GridBagConstraints cTotalPan = new DefaultGridBagConstraints();

    JPanel panelTotalHT = new JPanel();
    panelTotalHT.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    cTotalPan.anchor = GridBagConstraints.WEST;
    final JLabelBold labelTotalHT = new JLabelBold(getLabelFor("TOTAL_HT"));
    panelTotalHT.add(labelTotalHT, cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    this.textTotalHT.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalHT);
    panelTotalHT.add(this.textTotalHT, cTotalPan);
    this.add(panelTotalHT, c);

    JPanel panelTotalTVA = new JPanel();
    panelTotalTVA.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.weightx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.fill = GridBagConstraints.HORIZONTAL;
    panelTotalTVA.add(new JLabelBold(getLabelFor("TOTAL_TVA")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    cTotalPan.weightx = 1;
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTVA);
    panelTotalTVA.add(this.textTotalTVA, cTotalPan);
    c.gridy++;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(panelTotalTVA, c);

    JPanel panelTotalTTC = new JPanel();
    panelTotalTTC.setLayout(new GridBagLayout());
    cTotalPan.gridx = 0;
    cTotalPan.anchor = GridBagConstraints.WEST;
    cTotalPan.gridwidth = GridBagConstraints.REMAINDER;
    cTotalPan.fill = GridBagConstraints.BOTH;
    cTotalPan.weightx = 1;
    panelTotalTTC.add(new JSeparator(), cTotalPan);
    cTotalPan.gridwidth = 1;
    cTotalPan.fill = GridBagConstraints.NONE;
    cTotalPan.weightx = 0;
    cTotalPan.gridy++;
    panelTotalTTC.add(new JLabelBold(getLabelFor("TOTAL_TTC")), cTotalPan);
    cTotalPan.anchor = GridBagConstraints.EAST;
    cTotalPan.gridx++;
    this.textTotalTTC.setFont(labelTotalHT.getFont());
    DefaultGridBagConstraints.lockMinimumSize(this.textTotalTTC);
    panelTotalTTC.add(this.textTotalTTC, cTotalPan);
    c.gridy++;
    // probleme de tremblement vertical
    this.add(panelTotalTTC, c);
    c.anchor = GridBagConstraints.WEST;

    /*******************************************************************************************
     * * INFORMATIONS COMPLEMENTAIRES
     ******************************************************************************************/
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;
    c.gridy++;
    TitledSeparator sep = new TitledSeparator("Informations complmentaires");
    c.insets = new Insets(10, 2, 1, 2);
    this.add(sep, c);
    c.insets = new Insets(2, 2, 1, 2);

    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final ITextArea textInfos = new ITextArea(4, 4);
    JScrollPane scrollPane = new JScrollPane(textInfos);
    DefaultGridBagConstraints.lockMinimumSize(scrollPane);

    this.add(textInfos, c);

    this.addRequiredSQLObject(date, "DATE");
    this.addSQLObject(textInfos, "INFOS");
    this.addSQLObject(this.textReference, "NOM");
    this.addSQLObject(this.selectCommande, "ID_COMMANDE");
    this.addRequiredSQLObject(this.textNumeroUnique, "NUMERO");
    this.addSQLObject(this.textPoidsTotal, "TOTAL_POIDS");
    this.addRequiredSQLObject(this.textTotalHT, "TOTAL_HT");
    this.addRequiredSQLObject(this.textTotalTVA, "TOTAL_TVA");
    this.addRequiredSQLObject(this.textTotalTTC, "TOTAL_TTC");
    this.addRequiredSQLObject(this.fournisseur, "ID_FOURNISSEUR");

    this.textNumeroUnique.setText(NumerotationAutoSQLElement.getNextNumero(BonReceptionSQLElement.class));

    // Listeners
    this.tableBonItem.getModel().addTableModelListener(new TableModelListener() {
        public void tableChanged(TableModelEvent e) {

            int columnIndexHT = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalHTElement());
            int columnIndexTTC = BonReceptionSQLComponent.this.tableBonItem.getModel().getColumnIndexForElement(
                    BonReceptionSQLComponent.this.tableBonItem.getPrixTotalTTCElement());
            int columnIndexPoids = BonReceptionSQLComponent.this.tableBonItem.getModel()
                    .getColumnIndexForElement(
                            BonReceptionSQLComponent.this.tableBonItem.getPoidsTotalElement());

            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexHT
                    || e.getColumn() == columnIndexTTC) {
                updateTotal();
            }
            if (e.getColumn() == TableModelEvent.ALL_COLUMNS || e.getColumn() == columnIndexPoids) {
                BonReceptionSQLComponent.this.textPoidsTotal.setText(String
                        .valueOf(Math.round(BonReceptionSQLComponent.this.tableBonItem.getPoidsTotal() * 1000)
                                / 1000.0));
            }
        }
    });

    // Lock UI
    DefaultGridBagConstraints.lockMinimumSize(this.fournisseur);

}

From source file:org.openconcerto.erp.core.sales.order.component.CommandeClientSQLComponent.java

public void addViews() {
    this.setLayout(new GridBagLayout());
    final GridBagConstraints c = new DefaultGridBagConstraints();

    // Numero du commande
    c.gridx = 0;//from w  w w. ja v a  2  s .co  m
    this.add(new JLabel(getLabelFor("NUMERO"), SwingConstants.RIGHT), c);

    this.numeroUniqueCommande = new JUniqueTextField(16);
    c.fill = GridBagConstraints.NONE;
    c.gridx++;
    c.weightx = 1;
    this.add(this.numeroUniqueCommande, c);

    // Date
    JLabel labelDate = new JLabel(getLabelFor("DATE"));
    labelDate.setHorizontalAlignment(SwingConstants.RIGHT);
    c.gridx = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0;
    this.add(labelDate, c);

    JDate dateCommande = new JDate(true);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    this.add(dateCommande, c);

    // Champ Module
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = GridBagConstraints.REMAINDER;
    final JPanel addP = ComptaSQLConfElement.createAdditionalPanel();

    this.setAdditionalFieldsPanel(new FormLayouter(addP, 2));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 1;
    this.add(addP, c);

    c.gridy++;
    c.gridwidth = 1;

    this.comboDevis = new ElementComboBox();

    // Reference
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.fill = GridBagConstraints.HORIZONTAL;

    JLabel labelObjet = new JLabel(getLabelFor("NOM"));
    labelObjet.setHorizontalAlignment(SwingConstants.RIGHT);
    c.weightx = 0;
    this.add(labelObjet, c);

    c.gridx++;
    c.weightx = 1;
    c.fill = GridBagConstraints.BOTH;
    this.add(this.textObjet, c);

    String field;
    field = "ID_COMMERCIAL";
    c.fill = GridBagConstraints.HORIZONTAL;
    // Commercial
    JLabel labelCommercial = new JLabel(getLabelFor(field));
    labelCommercial.setHorizontalAlignment(SwingConstants.RIGHT);

    c.gridx++;
    c.weightx = 0;
    this.add(labelCommercial, c);

    this.comboCommercial = new ElementComboBox(false, 25);
    this.comboCommercial.setListIconVisible(false);
    c.gridx++;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 1;
    this.add(this.comboCommercial, c);
    addRequiredSQLObject(this.comboCommercial, field);

    // Ligne 3: Client
    c.gridx = 0;
    c.gridy++;
    c.weightx = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    this.add(new JLabel(getLabelFor("ID_CLIENT"), SwingConstants.RIGHT), c);

    this.comboClient = new ElementComboBox();
    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 3;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(this.comboClient, c);
    final ElementComboBox boxTarif = new ElementComboBox();
    this.comboClient.addValueListener(new PropertyChangeListener() {

        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (!isFilling() && comboClient.getValue() != null) {
                Integer id = comboClient.getValue();

                if (id > 1) {

                    SQLRow row = comboClient.getElement().getTable().getRow(id);
                    if (comboClient.getElement().getTable().getFieldsName().contains("ID_TARIF")) {

                        SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        if (!foreignRow.isUndefined()
                                && (boxTarif.getSelectedRow() == null
                                        || boxTarif.getSelectedId() != foreignRow.getID())
                                && JOptionPane.showConfirmDialog(null,
                                        "Appliquer les tarifs associs au client?") == JOptionPane.YES_OPTION) {
                            boxTarif.setValue(foreignRow.getID());
                            // SaisieVenteFactureSQLComponent.this.tableFacture.setTarif(foreignRow,
                            // true);
                        } else {
                            boxTarif.setValue(foreignRow.getID());
                        }
                        // SQLRowAccessor foreignRow = row.getForeignRow("ID_TARIF");
                        // if (foreignRow.isUndefined() &&
                        // !row.getForeignRow("ID_DEVISE").isUndefined()) {
                        // SQLRowValues rowValsD = new SQLRowValues(foreignRow.getTable());
                        // rowValsD.put("ID_DEVISE", row.getObject("ID_DEVISE"));
                        // foreignRow = rowValsD;
                        //
                        // }
                        // table.setTarif(foreignRow, true);
                    }
                }
            }

        }
    });
    // tarif
    if (this.getTable().getFieldsName().contains("ID_TARIF")) {
        // TARIF
        c.gridy++;
        c.gridx = 0;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        this.add(new JLabel("Tarif  appliquer"), c);
        c.gridx++;
        c.gridwidth = GridBagConstraints.REMAINDER;

        c.weightx = 1;
        this.add(boxTarif, c);
        this.addView(boxTarif, "ID_TARIF");
        boxTarif.addModelListener("wantedID", new PropertyChangeListener() {

            @Override
            public void propertyChange(PropertyChangeEvent evt) {
                SQLRow selectedRow = boxTarif.getRequest().getPrimaryTable().getRow(boxTarif.getWantedID());
                table.setTarif(selectedRow, false);
            }
        });
    }

    // Table d'lment
    this.table = new CommandeClientItemTable();
    c.fill = GridBagConstraints.BOTH;
    c.gridy++;
    c.gridx = 0;
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.table, c);

    DeviseField textPortHT = new DeviseField();
    DeviseField textRemiseHT = new DeviseField();

    // INfos
    c.gridx = 0;
    c.gridy++;
    c.gridheight = 1;
    c.weighty = 0;
    c.weightx = 1;
    c.anchor = GridBagConstraints.WEST;
    c.gridwidth = 2;
    this.add(new TitledSeparator(getLabelFor("INFOS")), c);

    c.gridy++;
    c.weightx = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.BOTH;
    final JScrollPane scrollPane = new JScrollPane(this.infos);
    scrollPane.setBorder(null);
    this.add(scrollPane, c);

    // Poids
    c.gridwidth = 1;

    DefaultProps props = DefaultNXProps.getInstance();
    Boolean b = props.getBooleanValue("ArticleShowPoids");
    final JTextField textPoidsTotal = new JTextField(8);
    if (b) {
        JPanel panel = new JPanel();

        panel.add(new JLabel(getLabelFor("T_POIDS")), c);

        textPoidsTotal.setEnabled(false);
        textPoidsTotal.setHorizontalAlignment(JTextField.RIGHT);
        textPoidsTotal.setDisabledTextColor(Color.BLACK);
        panel.add(textPoidsTotal, c);

        panel.setOpaque(false);
        DefaultGridBagConstraints.lockMinimumSize(panel);

        c.gridx = 2;
        c.weightx = 0;
        c.weighty = 0;
        c.gridwidth = 1;
        c.fill = GridBagConstraints.NONE;
        c.anchor = GridBagConstraints.NORTHEAST;
        this.add(panel, c);
    }

    // Total
    DeviseField fieldHT = new DeviseField();
    DeviseField fieldTVA = new DeviseField();
    DeviseField fieldTTC = new DeviseField();
    DeviseField fieldDevise = new DeviseField();
    DeviseField fieldService = new DeviseField();
    DeviseField fieldHA = new DeviseField();
    fieldHT.setOpaque(false);
    fieldHA.setOpaque(false);
    fieldTVA.setOpaque(false);
    fieldTTC.setOpaque(false);
    fieldService.setOpaque(false);
    addSQLObject(fieldDevise, "T_DEVISE");
    addRequiredSQLObject(fieldHT, "T_HT");
    addRequiredSQLObject(fieldTVA, "T_TVA");
    addRequiredSQLObject(fieldTTC, "T_TTC");
    addRequiredSQLObject(fieldService, "T_SERVICE");
    if (getTable().contains("PREBILAN")) {
        addSQLObject(fieldHA, "PREBILAN");
    } else if (getTable().contains("T_HA")) {
        addSQLObject(fieldHA, "T_HA");
    }

    JTextField poids = new JTextField();
    // addSQLObject(poids, "T_POIDS");
    final TotalPanel totalTTC = new TotalPanel(this.table, fieldHT, fieldTVA, fieldTTC, textPortHT,
            textRemiseHT, fieldService, fieldHA, fieldDevise, poids, null);

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridy--;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 2;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 0;

    this.add(totalTTC, c);

    this.panelOO = new PanelOOSQLComponent(this);
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.EAST;
    c.gridx = 0;
    c.gridy += 3;
    c.weightx = 0;
    c.gridwidth = GridBagConstraints.REMAINDER;
    this.add(this.panelOO, c);

    textPortHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    textRemiseHT.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void removeUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }

        public void insertUpdate(DocumentEvent e) {
            totalTTC.updateTotal();
        }
    });

    addRequiredSQLObject(this.comboClient, "ID_CLIENT");
    addSQLObject(this.textObjet, "NOM");
    addSQLObject(textPoidsTotal, "T_POIDS");
    addRequiredSQLObject(dateCommande, "DATE");
    // addRequiredSQLObject(radioEtat, "ID_ETAT_DEVIS");
    addRequiredSQLObject(this.numeroUniqueCommande, "NUMERO");
    addSQLObject(this.infos, "INFOS");
    addSQLObject(this.comboDevis, "ID_DEVIS");

    this.numeroUniqueCommande
            .setText(NumerotationAutoSQLElement.getNextNumero(CommandeClientSQLElement.class, new Date()));

    this.table.getModel().addTableModelListener(new TableModelListener() {

        public void tableChanged(TableModelEvent e) {
            textPoidsTotal.setText(String.valueOf(CommandeClientSQLComponent.this.table.getPoidsTotal()));
        }
    });
    DefaultGridBagConstraints.lockMinimumSize(comboClient);
    DefaultGridBagConstraints.lockMinimumSize(comboCommercial);
    DefaultGridBagConstraints.lockMinimumSize(comboDevis);
    DefaultGridBagConstraints.lockMinimumSize(totalTTC);
    DefaultGridBagConstraints.lockMaximumSize(totalTTC);
    DefaultGridBagConstraints.lockMinimumSize(numeroUniqueCommande);

}

From source file:gda.gui.mca.McaGUI.java

private JPanel getAdcPanel() {
    gainLabel = new JLabel("Gain");
    offsetLabel = new JLabel("Offset");
    lldLabel = new JLabel("LLD");
    gainField = new JTextField(10);
    gainField.addActionListener(new ActionListener() {

        @Override//from  w  ww.  ja  v a2  s . com
        public void actionPerformed(ActionEvent e) {
            setAdcValues();

        }

    });
    offsetField = new JTextField(10);
    offsetField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setAdcValues();

        }

    });
    lldField = new JTextField(10);
    lldField.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setAdcValues();

        }

    });
    adcPanel = new JPanel();
    adcPanel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = GridBagConstraints.RELATIVE;
    gc.gridy = 0;
    adcPanel.add(gainLabel, gc);
    adcPanel.add(gainField, gc);
    gc.gridx = 0;
    gc.gridy = GridBagConstraints.RELATIVE;
    adcPanel.add(offsetLabel, gc);
    gc.gridx = GridBagConstraints.RELATIVE;
    gc.gridy = 1;
    adcPanel.add(offsetField, gc);
    gc.gridx = 0;
    gc.gridy = 2;
    adcPanel.add(lldLabel, gc);
    gc.gridx = GridBagConstraints.RELATIVE;
    adcPanel.add(lldField, gc);
    adcPanel.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(), "ADC"));
    return adcPanel;
}

From source file:com.limegroup.gnutella.gui.LicenseWindow.java

protected void createValid() {
    GridBagConstraints c = new GridBagConstraints();
    JComponent label = new JLabel(getDetailsString());
    Font f = label.getFont();//from  w  w  w .j a  v a  2  s . co m
    label.setFont(new Font(f.getName(), Font.BOLD, f.getSize()));
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.NORTHWEST;
    DETAILS.add(label, c);

    JTextArea text = newTextArea(LICENSE.getLicenseDescription(URN));
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.gridheight = 2;
    c.weighty = 1;
    c.weightx = .7;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    DETAILS.add(text, c);

    if (LICENSE.getLicenseDeed(URN) != null) {
        label = new URLLabel(LICENSE.getLicenseDeed(URN), getDeedString());
    } else {
        label = new JLabel();
        label.setVisible(false);
    }
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.gridheight = 1;
    c.weighty = 0;
    c.weightx = .3;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(0, 0, 3, 0);
    DETAILS.add(label, c);

    label = new URLLabel(LICENSE.getLicenseURI(), getVerificationString());
    DETAILS.add(label, c);
}

From source file:TextSamplerDemo.java

private void addLabelTextRows(JLabel[] labels, JTextField[] textFields, GridBagLayout gridbag,
        Container container) {//from   w  ww  .  j a  va2  s.c om
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.EAST;
    int numLabels = labels.length;

    for (int i = 0; i < numLabels; i++) {
        c.gridwidth = GridBagConstraints.RELATIVE; //next-to-last
        c.fill = GridBagConstraints.NONE; //reset to default
        c.weightx = 0.0; //reset to default
        container.add(labels[i], c);

        c.gridwidth = GridBagConstraints.REMAINDER; //end row
        c.fill = GridBagConstraints.HORIZONTAL;
        c.weightx = 1.0;
        container.add(textFields[i], c);
    }
}

From source file:com.xmage.launcher.XMageLauncher.java

private XMageLauncher() {
    locale = Locale.getDefault();
    //locale = new Locale("it", "IT");
    messages = ResourceBundle.getBundle("MessagesBundle", locale);
    localize();//w  w w  . ja  va 2  s  .  c  o m

    serverConsole = new XMageConsole("XMage Server console");
    clientConsole = new XMageConsole("XMage Client console");

    frame = new JFrame(messages.getString("frameTitle") + " " + Config.getVersion());
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setPreferredSize(new Dimension(800, 500));
    frame.setResizable(false);

    createToolbar();

    ImageIcon icon = new ImageIcon(XMageLauncher.class.getResource("/icon-mage-flashed.png"));
    frame.setIconImage(icon.getImage());

    Random r = new Random();
    int imageNum = 1 + r.nextInt(17);
    ImageIcon background = new ImageIcon(new ImageIcon(
            XMageLauncher.class.getResource("/backgrounds/" + Integer.toString(imageNum) + ".jpg")).getImage()
                    .getScaledInstance(800, 480, Image.SCALE_SMOOTH));
    mainPanel = new JLabel(background) {
        @Override
        public Dimension getPreferredSize() {
            Dimension size = super.getPreferredSize();
            Dimension lmPrefSize = getLayout().preferredLayoutSize(this);
            size.width = Math.max(size.width, lmPrefSize.width);
            size.height = Math.max(size.height, lmPrefSize.height);
            return size;
        }
    };
    mainPanel.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            grabPoint = e.getPoint();
            mainPanel.getComponentAt(grabPoint);
        }
    });
    mainPanel.addMouseMotionListener(new MouseMotionAdapter() {
        @Override
        public void mouseDragged(MouseEvent e) {

            // get location of Window
            int thisX = frame.getLocation().x;
            int thisY = frame.getLocation().y;

            // Determine how much the mouse moved since the initial click
            int xMoved = (thisX + e.getX()) - (thisX + grabPoint.x);
            int yMoved = (thisY + e.getY()) - (thisY + grabPoint.y);

            // Move window to this position
            int X = thisX + xMoved;
            int Y = thisY + yMoved;
            frame.setLocation(X, Y);
        }
    });
    mainPanel.setLayout(new GridBagLayout());

    GridBagConstraints constraints = new GridBagConstraints();
    constraints.insets = new Insets(10, 10, 10, 10);

    Font font16 = new Font("Arial", Font.BOLD, 16);
    Font font12 = new Font("Arial", Font.PLAIN, 12);
    Font font12b = new Font("Arial", Font.BOLD, 12);

    mainPanel.add(Box.createRigidArea(new Dimension(250, 50)));

    ImageIcon logo = new ImageIcon(new ImageIcon(XMageLauncher.class.getResource("/label-xmage.png")).getImage()
            .getScaledInstance(150, 75, Image.SCALE_SMOOTH));
    xmageLogo = new JLabel(logo);
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.gridheight = 1;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.anchor = GridBagConstraints.EAST;
    mainPanel.add(xmageLogo, constraints);

    textArea = new JTextArea(5, 40);
    textArea.setEditable(false);
    textArea.setForeground(Color.WHITE);
    textArea.setBackground(Color.BLACK);
    DefaultCaret caret = (DefaultCaret) textArea.getCaret();
    caret.setUpdatePolicy(DefaultCaret.ALWAYS_UPDATE);
    scrollPane = new JScrollPane(textArea);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    constraints.gridx = 2;
    constraints.gridy = 1;
    constraints.weightx = 1.0;
    constraints.weighty = 1.0;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(scrollPane, constraints);

    labelProgress = new JLabel(messages.getString("progress"));
    labelProgress.setFont(font12);
    labelProgress.setForeground(Color.WHITE);
    constraints.gridy = 2;
    constraints.weightx = 0.0;
    constraints.weighty = 0.0;
    constraints.gridwidth = 1;
    constraints.anchor = GridBagConstraints.WEST;
    mainPanel.add(labelProgress, constraints);

    progressBar = new JProgressBar(0, 100);
    constraints.gridx = 3;
    constraints.weightx = 1.0;
    constraints.gridwidth = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(progressBar, constraints);

    JPanel pnlButtons = new JPanel();
    pnlButtons.setLayout(new GridBagLayout());
    pnlButtons.setOpaque(false);
    constraints.gridx = 0;
    constraints.gridy = 3;
    constraints.gridheight = GridBagConstraints.REMAINDER;
    constraints.fill = GridBagConstraints.BOTH;
    mainPanel.add(pnlButtons, constraints);

    btnLaunchClient = new JButton(messages.getString("launchClient"));
    btnLaunchClient.setToolTipText(messages.getString("launchClient.tooltip"));
    btnLaunchClient.setFont(font16);
    btnLaunchClient.setForeground(Color.GRAY);
    btnLaunchClient.setEnabled(false);
    btnLaunchClient.setPreferredSize(new Dimension(180, 60));
    btnLaunchClient.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleClient();
        }
    });

    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.gridy = 0;
    constraints.gridwidth = 1;
    constraints.fill = GridBagConstraints.BOTH;
    pnlButtons.add(btnLaunchClient, constraints);

    btnLaunchClientServer = new JButton(messages.getString("launchClientServer"));
    btnLaunchClientServer.setToolTipText(messages.getString("launchClientServer.tooltip"));
    btnLaunchClientServer.setFont(font12b);
    btnLaunchClientServer.setEnabled(false);
    btnLaunchClientServer.setForeground(Color.GRAY);
    btnLaunchClientServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchClientServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
            handleClient();
        }
    });

    constraints.fill = GridBagConstraints.HORIZONTAL;
    pnlButtons.add(btnLaunchClientServer, constraints);

    btnLaunchServer = new JButton(messages.getString("launchServer"));
    btnLaunchServer.setToolTipText(messages.getString("launchServer.tooltip"));
    btnLaunchServer.setFont(font12b);
    btnLaunchServer.setEnabled(false);
    btnLaunchServer.setForeground(Color.GRAY);
    btnLaunchServer.setPreferredSize(new Dimension(80, 40));
    btnLaunchServer.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleServer();
        }
    });

    pnlButtons.add(btnLaunchServer, constraints);

    btnUpdate = new JButton(messages.getString("update.xmage"));
    btnUpdate.setToolTipText(messages.getString("update.xmage.tooltip"));
    btnUpdate.setFont(font12b);
    btnUpdate.setForeground(Color.BLACK);
    btnUpdate.setPreferredSize(new Dimension(80, 40));
    btnUpdate.setEnabled(true);

    btnUpdate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleUpdate();
        }
    });

    pnlButtons.add(btnUpdate, constraints);

    btnCheck = new JButton(messages.getString("check.xmage"));
    btnCheck.setToolTipText(messages.getString("check.xmage.tooltip"));
    btnCheck.setFont(font12b);
    btnCheck.setForeground(Color.BLACK);
    btnCheck.setPreferredSize(new Dimension(80, 40));
    btnCheck.setEnabled(true);

    btnCheck.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleCheckUpdates();
        }
    });

    pnlButtons.add(btnCheck, constraints);

    frame.add(mainPanel);
    frame.pack();
    Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
    frame.setLocation(dim.width / 2 - frame.getSize().width / 2, dim.height / 2 - frame.getSize().height / 2);
}

From source file:org.photovault.swingui.PhotoInfoEditor.java

protected void createUI() {
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10));
    tabPane = new JTabbedPane();
    add(tabPane, BorderLayout.CENTER);

    // General pane
    JPanel generalPane = new JPanel();
    tabPane.addTab("General", generalPane);

    // Create the fields & their labels

    // Photographer field
    JLabel photographerLabel = new JLabel("Photographer");
    photographerField = createMvTextField("photographer", 30);
    photographerDoc = photographerField.getDocument();

    // "Fuzzy time" field
    JLabel fuzzyDateLabel = new JLabel("Shooting date");
    fuzzyDateField = new JTextField(30);
    fuzzyDateDoc = fuzzyDateField.getDocument();
    fuzzyDateDoc.putProperty(FIELD, PhotoInfoFields.FUZZY_SHOOT_TIME);
    fuzzyDateDoc.addDocumentListener(this);

    JLabel qualityLabel = new JLabel("Quality");
    qualityField = new JComboBox(qualityStrings);
    qualityField.addActionListener(this);

    StarRating qualityStars = new StarRating(5);
    FieldController<Integer> qfCtrl = ctrl.getFieldController("quality");
    ValueModel qualityFieldValue = new PropertyAdapter(qfCtrl, "value", true);
    ValueModel starCount = new PropertyAdapter(qualityStars, "selection", true);
    PropertyConnector.connect(qualityFieldValue, "value", starCount, "value");

    // Shooting place field
    JLabel shootingPlaceLabel = new JLabel("Shooting place");
    shootingPlaceField = createMvTextField("shotLocation.description", 30);
    shootingPlaceDoc = shootingPlaceField.getDocument();
    JLabel shotLocRoadLabel = new JLabel("Road");
    JTextField shotLocRoadField = createMvTextField("shotLocation.road", 30);
    JLabel shotLocSuburbLabel = new JLabel("Suburb");
    JTextField shotLocSuburbField = createMvTextField("shotLocation.suburb", 30);
    JLabel shotLocCityLabel = new JLabel("City");
    JTextField shotLocCityField = createMvTextField("shotLocation.city", 30);
    JLabel shotLocCountryLabel = new JLabel("Country");
    JTextField shotLocCountryField = createMvTextField("shotLocation.country", 30);
    JLabel shotLocGeohashLabel = new JLabel("Geohash code");
    JTextField shotLocGeohashField = createMvTextField("shotLocation.geoHashString", 30);
    shotLocGeohashField.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_F2, 0), "fillAddress");
    shotLocGeohashField.getActionMap().put("fillAddress", new FindAddressAction(ctrl));

    // Tags//  www .  j  ava2  s  . c  o  m
    JLabel tagLabel = new JLabel("Tags");
    tagList = new TagList2(ctrl.getTagController());
    tagList.setBackground(generalPane.getBackground());

    // Description text
    JLabel descLabel = new JLabel("Description");
    descriptionTextArea = new JTextArea(5, 40);
    descriptionTextArea.setLineWrap(true);
    descriptionTextArea.setWrapStyleWord(true);
    JScrollPane descScrollPane = new JScrollPane(descriptionTextArea);
    descScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    Border descBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    descBorder = BorderFactory.createTitledBorder(descBorder, "Description");
    descScrollPane.setBorder(descBorder);
    descriptionDoc = descriptionTextArea.getDocument();
    descriptionDoc.putProperty(FIELD, PhotoInfoFields.DESCRIPTION);
    descriptionDoc.addDocumentListener(this);

    // Lay out the created controls
    GridBagLayout layout = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    generalPane.setLayout(layout);
    JLabel[] labels = { photographerLabel, fuzzyDateLabel, shootingPlaceLabel, shotLocGeohashLabel,
            shotLocRoadLabel, shotLocSuburbLabel, shotLocCityLabel, shotLocCountryLabel, qualityLabel,
            tagLabel };
    JComponent[] fields = { photographerField, fuzzyDateField, shootingPlaceField, shotLocGeohashField,
            shotLocRoadField, shotLocSuburbField, shotLocCityField, shotLocCountryField, qualityStars,
            tagList };
    addLabelTextRows(labels, fields, layout, generalPane);
    c = layout.getConstraints(tagList);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.weightx = 0.0;
    c.weighty = 1.0;
    layout.setConstraints(tagList, c);

    generalPane.add(descScrollPane);
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    layout.setConstraints(descScrollPane, c);

    c = new GridBagConstraints();
    c.gridwidth = 1;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridy = GridBagConstraints.RELATIVE;

    c.gridy = GridBagConstraints.RELATIVE;

    createTechDataUI();
    createFolderPaneUI();
    createRightsUI();
}

From source file:org.openconcerto.erp.core.finance.accounting.ui.EtatJournauxPanel.java

private JPanel initJournalPanel(final Journal jrnl) {

    final JPanel panelTmp = new JPanel();
    long totalDebitJournal = 0;
    long totalCreditJournal = 0;

    panelTmp.setLayout(new GridBagLayout());

    final GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(2, 2, 1, 2);
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.gridx = 0;// www  .j  ava  2s  .c  om
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 1;
    c.weighty = 0;

    String req = "SELECT DISTINCT EXTRACT(YEAR FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\"), "
            + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")," + " SUM(\"" + baseName
            + "\".\"ECRITURE\".\"DEBIT\"), " + "SUM(\"" + baseName + "\".\"ECRITURE\".\"CREDIT\")" + " FROM \""
            + baseName + "\".\"ECRITURE\" " + "WHERE (\"" + baseName + "\".\"ECRITURE\".\"ID\" != 1) "
            + "AND ((\"" + baseName + "\".\"ECRITURE\".\"ARCHIVE\" = 0) " + "AND (\"" + baseName
            + "\".\"ECRITURE\".\"ID_JOURNAL\" = " + jrnl.getId() + ")) " + "GROUP BY EXTRACT(YEAR FROM \""
            + baseName + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName
            + "\".\"ECRITURE\".\"DATE\") " + "ORDER BY EXTRACT(YEAR FROM \"" + baseName
            + "\".\"ECRITURE\".\"DATE\"), " + "EXTRACT(MONTH FROM \"" + baseName + "\".\"ECRITURE\".\"DATE\")";
    System.out.println(req);

    Object ob = base.getDataSource().execute(req, new ArrayListHandler());

    List myList = (List) ob;

    // System.err.println("TEST DATE " + t);

    if (myList.size() != 0) {

        for (int i = 0; i < myList.size(); i++) {

            Object[] objTmp = (Object[]) myList.get(i);

            Calendar cal = Calendar.getInstance();
            cal.set(Calendar.DATE, 1);
            int month = (new Double(objTmp[1].toString()).intValue() - 1);
            System.err.println(jrnl.getNom() + " SET MONTH " + month);
            cal.set(Calendar.MONTH, month);
            System.err.println(month + " = " + cal.getTime());

            cal.set(Calendar.YEAR, new Double(objTmp[0].toString()).intValue());

            long debitMois = ((Number) objTmp[2]).longValue();
            long creditMois = ((Number) objTmp[3]).longValue();

            c.gridwidth = GridBagConstraints.REMAINDER;
            final JPanel creerJournalMoisPanel = creerJournalMoisPanel(cal.getTime(), debitMois, creditMois,
                    jrnl);
            creerJournalMoisPanel.setOpaque(false);
            panelTmp.add(creerJournalMoisPanel, c);

            c.gridy++;

            totalDebitJournal += debitMois;
            totalCreditJournal += creditMois;
        }
    }
    c.gridx = 0;
    c.weighty = 1;
    c.gridwidth = 1;
    final JLabel label = new JLabel("Journal " + jrnl.getNom());
    label.setOpaque(false);
    panelTmp.add(label, c);
    c.gridx = GridBagConstraints.RELATIVE;
    panelTmp.add(new JLabel(" Total dbit : " + GestionDevise.currencyToString(totalDebitJournal)), c);
    panelTmp.add(new JLabel(" Total crdit : " + GestionDevise.currencyToString(totalCreditJournal)), c);

    return panelTmp;
}