Example usage for java.awt GridBagConstraints REMAINDER

List of usage examples for java.awt GridBagConstraints REMAINDER

Introduction

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

Prototype

int REMAINDER

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

Click Source Link

Document

Specifies that this component is the last component in its column or row.

Usage

From source file:com.intel.stl.ui.main.view.NodeStatesPie.java

/**
 * Description:/*from w  ww  . jav a2 s .  co m*/
 * 
 */
protected void initcomponent() {
    setLayout(new GridBagLayout());

    chartPanel = new ChartPanel(null);
    chartPanel.setPreferredSize(new Dimension(120, 90));

    GridBagConstraints gc = new GridBagConstraints();
    if (concise) {
        gc.gridwidth = GridBagConstraints.REMAINDER;
    }
    add(chartPanel, gc);

    if (!concise) {
        gc.fill = GridBagConstraints.BOTH;
        gc.weightx = 1;
        gc.gridwidth = GridBagConstraints.REMAINDER;
        legendPanel = new JPanel();
        legendPanel.setOpaque(false);
        legendPanel.setLayout(new GridBagLayout());
        add(legendPanel, gc);
    }
}

From source file:com.sshtools.common.ui.SshToolsConnectionHostTab.java

/**
 * Creates a new SshToolsConnectionHostTab object.
 *//*w w  w  .  j a  v  a2  s  .  c o  m*/
public SshToolsConnectionHostTab() {
    super();

    //  Create the main connection details panel
    JPanel mainConnectionDetailsPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(0, 2, 2, 2);
    gbc.weightx = 1.0;

    //  Host name
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Hostname"), gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextHostname, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.NONE;

    //  Port
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextPort, gbc, GridBagConstraints.REMAINDER);

    //  Username
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(mainConnectionDetailsPanel, jTextUsername, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.NONE;

    //
    IconWrapperPanel iconMainConnectionDetailsPanel = new IconWrapperPanel(
            new ResourceIcon(SshToolsConnectionHostTab.class, CONNECT_ICON), mainConnectionDetailsPanel);

    //  Authentication methods panel
    JPanel authMethodsPanel = new JPanel(new GridBagLayout());
    authMethodsPanel.setBorder(BorderFactory.createEmptyBorder(4, 0, 0, 0));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 2;

    GridBagConstraints gbc2 = new GridBagConstraints();
    gbc2.fill = GridBagConstraints.HORIZONTAL;
    gbc2.anchor = GridBagConstraints.NORTHWEST;
    gbc2.insets = new Insets(2, 2, 2, 2);
    gbc2.weightx = 1.0;
    gbc2.weighty = 0.0;
    gbc2.gridx = 0;
    gbc2.gridy = 1;
    gbc2.gridwidth = 2;

    GridBagConstraints gbc3 = new GridBagConstraints();
    gbc3.fill = GridBagConstraints.HORIZONTAL;
    gbc3.anchor = GridBagConstraints.NORTHWEST;
    gbc3.insets = new Insets(2, 2, 2, 2);
    gbc3.weightx = 1.0;
    gbc3.weighty = 0.0;
    gbc3.gridx = 0;
    gbc3.gridy = 2;
    gbc3.gridwidth = 2;

    GridBagConstraints gbc4 = new GridBagConstraints();
    gbc4.fill = GridBagConstraints.HORIZONTAL;
    gbc4.anchor = GridBagConstraints.NORTHWEST;
    gbc4.insets = new Insets(26, 2, 2, 2);
    gbc4.weightx = 0.0;
    gbc4.weighty = 0.0;
    gbc4.gridx = 0;
    gbc4.gridy = 3;
    gbc4.gridwidth = 1;

    GridBagConstraints gbc5 = new GridBagConstraints();
    gbc5.fill = GridBagConstraints.NONE;
    gbc5.anchor = GridBagConstraints.WEST;
    gbc5.insets = new Insets(26, 2, 2, 2);
    gbc5.weightx = 1.0;
    gbc5.weighty = 0.0;
    gbc5.gridx = 1;
    gbc5.gridy = 3;
    gbc5.gridwidth = 1;

    GridBagConstraints gbc6 = new GridBagConstraints();
    gbc6.fill = GridBagConstraints.HORIZONTAL;
    gbc6.anchor = GridBagConstraints.NORTHWEST;
    gbc6.insets = new Insets(12, 2, 2, 2);
    gbc6.weightx = 0.0;
    gbc6.weighty = 0.0;
    gbc6.gridx = 0;
    gbc6.gridy = 4;
    gbc6.gridwidth = 1;

    GridBagConstraints gbc7 = new GridBagConstraints();
    gbc7.fill = GridBagConstraints.NONE;
    gbc7.anchor = GridBagConstraints.WEST;
    gbc7.insets = new Insets(12, 2, 2, 2);
    gbc7.weightx = 1.0;
    gbc7.weighty = 0.0;
    gbc7.gridx = 1;
    gbc7.gridy = 4;
    gbc7.gridwidth = 1;

    GridBagConstraints gbc8 = new GridBagConstraints();
    gbc8.fill = GridBagConstraints.HORIZONTAL;
    gbc8.anchor = GridBagConstraints.NORTHWEST;
    gbc8.insets = new Insets(12, 2, 2, 2);
    gbc8.weightx = 0.0;
    gbc8.weighty = 0.0;
    gbc8.gridx = 0;
    gbc8.gridy = 5;
    gbc8.gridwidth = 1;

    GridBagConstraints gbc9 = new GridBagConstraints();
    gbc9.fill = GridBagConstraints.NONE;
    gbc9.anchor = GridBagConstraints.WEST;
    gbc9.insets = new Insets(12, 2, 2, 2);
    gbc9.weightx = 1.0;
    gbc9.weighty = 0.0;
    gbc9.gridx = 1;
    gbc9.gridy = 5;
    gbc9.gridwidth = 1;

    GridBagConstraints gbc10 = new GridBagConstraints();
    gbc10.fill = GridBagConstraints.HORIZONTAL;
    gbc10.anchor = GridBagConstraints.NORTHWEST;
    gbc10.insets = new Insets(26, 2, 2, 2);
    gbc10.weightx = 1.0;
    gbc10.weighty = 0.0;
    gbc10.gridx = 0;
    gbc10.gridy = 6;
    gbc10.gridwidth = 2;

    //  Authentication methods
    authMethodsPanel.add(new JLabel("Authentication Methods"), gbc);
    jListAuths.setVisibleRowCount(5);
    authMethodsPanel.add(new JScrollPane(jListAuths), gbc2);

    allowAgentForwarding = new JCheckBox("Allow agent forwarding");
    authMethodsPanel.add(allowAgentForwarding, gbc3);

    String options[] = { "Full", "Limited", "None" };
    delegationOption = new JComboBox(options);
    delegationOption.setSelectedIndex(0);
    authMethodsPanel.add(new JLabel("Delegation Type:"), gbc4);
    authMethodsPanel.add(delegationOption, gbc5);

    String optionsP[] = { "Pre-RFC Impersonation", "RFC Impersonation", "Legacy" };
    proxyOption = new JComboBox(optionsP);
    proxyOption.setSelectedIndex(0);
    authMethodsPanel.add(new JLabel("Proxy Type:"), gbc6);
    authMethodsPanel.add(proxyOption, gbc7);

    authMethodsPanel.add(new JLabel("Proxy Lifetime (hours):"), gbc8);
    proxyLength.setColumns(5);
    authMethodsPanel.add(proxyLength, gbc9);
    gbc.gridx = 0;
    proxySave = new JCheckBox("Save Grid Proxies to Disk");
    authMethodsPanel.add(proxySave, gbc10);

    //
    IconWrapperPanel iconAuthMethodsPanel = new IconWrapperPanel(
            new ResourceIcon(SshToolsConnectionHostTab.class, AUTH_ICON), authMethodsPanel);

    //  This panel
    JPanel mine = new JPanel();
    mine.setLayout(new GridBagLayout());
    mine.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    mine.add(iconMainConnectionDetailsPanel, gbc);
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.insets = new Insets(20, 2, 2, 2);
    mine.add(iconAuthMethodsPanel, gbc);
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    this.add(mine, BorderLayout.NORTH);
    //  Set up the values in the various components
    addAuthenticationMethods();
}

From source file:com.sshtools.common.ui.SshToolsConnectionProxyTab.java

/**
 * Creates a new SshToolsConnectionProxyTab object.
 */// www. j a va  2s. c o m
public SshToolsConnectionProxyTab() {
    super();
    group.add(noProxy);
    group.add(httpProxy);
    group.add(socks4Proxy);
    group.add(socks5Proxy);

    ChangeListener listener = new ChangeListener() {
        public void stateChanged(ChangeEvent e) {
            if (noProxy.isSelected()) {
                username.setEnabled(false);
                password.setEnabled(false);
                proxy.setEnabled(false);

                //port.setEnabled(false);
                port.setForeground(Color.white);
            } else {
                username.setEnabled(true);
                password.setEnabled(true);
                proxy.setEnabled(true);

                //port.setEnabled(true);
                port.setForeground(Color.black);

                if (httpProxy.isSelected()) {
                    port.setText("80");
                } else {
                    port.setText("1080");
                }
            }
        }
    };

    noProxy.getModel().addChangeListener(listener);
    httpProxy.getModel().addChangeListener(listener);
    socks4Proxy.getModel().addChangeListener(listener);
    socks5Proxy.getModel().addChangeListener(listener);

    //  Create the main connection details panel
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(0, 2, 2, 2);
    gbc.weightx = 1.0;
    proxyframe.setBorder(BorderFactory.createTitledBorder("Connect using the following proxy"));

    //  No proxy label
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, noProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 4 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks4Proxy, gbc, GridBagConstraints.REMAINDER);

    //gbc.fill = GridBagConstraints.HORIZONTAL;
    // Http Proxy
    gbc.insets = new Insets(2, 10, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, httpProxy, gbc, GridBagConstraints.RELATIVE);

    // Socks 5 label
    gbc.insets = new Insets(2, 15, 2, 2);
    UIUtil.jGridBagAdd(proxyframe, socks5Proxy, gbc, GridBagConstraints.REMAINDER);

    gbc.insets = new Insets(2, 10, 2, 10);

    JPanel connect = new JPanel(new GridBagLayout());
    connect.setBorder(BorderFactory.createTitledBorder("Proxy Details"));
    UIUtil.jGridBagAdd(connect, new JLabel("Host"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, proxy, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Port"), gbc, GridBagConstraints.REMAINDER);
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.NONE;

    UIUtil.jGridBagAdd(connect, port, gbc, GridBagConstraints.REMAINDER);
    gbc.fill = GridBagConstraints.HORIZONTAL;

    UIUtil.jGridBagAdd(connect, new JLabel("Username"), gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, username, gbc, GridBagConstraints.REMAINDER);

    UIUtil.jGridBagAdd(connect, new JLabel("Password"), gbc, GridBagConstraints.REMAINDER);
    gbc.insets = new Insets(2, 10, 10, 10);
    UIUtil.jGridBagAdd(connect, password, gbc, GridBagConstraints.REMAINDER);

    JPanel main = new JPanel(new GridBagLayout());
    gbc.insets = new Insets(2, 2, 2, 2);
    UIUtil.jGridBagAdd(main, proxyframe, gbc, GridBagConstraints.REMAINDER);
    UIUtil.jGridBagAdd(main, connect, gbc, GridBagConstraints.REMAINDER);

    IconWrapperPanel iconProxyDetailsPanel = new IconWrapperPanel(new ResourceIcon(PROXY_ICON), main);
    noProxy.setSelected(true);

    //  This panel
    setLayout(new BorderLayout());
    setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.NORTH;
    gbc.insets = new Insets(2, 2, 2, 2);
    gbc.weightx = 1.0;
    add(iconProxyDetailsPanel, BorderLayout.NORTH);
}

From source file:org.intermine.install.swing.AddSourceDialog.java

/**
 * Common initialisation: lays out the child components and wires up the necessary
 * event listeners. /*  w ww . jav  a 2 s . co  m*/
 */
private void init() {
    setName("Add Source Dialog");
    setTitle(Messages.getMessage("source.add.title"));

    Container cp = getContentPane();

    GridBagConstraints cons = GridBagHelper.setup(cp);

    cp.add(new JLabel(Messages.getMessage("source.type")), cons);

    cons.gridy++;
    cp.add(new JLabel(Messages.getMessage("source.name")), cons);

    cons.gridx++;
    cons.gridy = 0;
    cons.weightx = 1;
    cp.add(typeCombo, cons);

    cons.gridy++;
    cp.add(nameField, cons);

    cons.gridx = 0;
    cons.gridy++;
    cons.gridwidth = GridBagConstraints.REMAINDER;
    cp.add(new ButtonPanel(addAction, new CancelAction()), cons);

    pack();

    nameField.getDocument().addDocumentListener(new NameDocumentListener());
    typeCombo.addActionListener(new TypeComboListener());
}

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

private void initComponents() {
    Dimension dimension = new Dimension(220, 22);
    setPreferredSize(dimension);/*from   ww w. j a v a 2 s.  com*/
    setMinimumSize(dimension);

    speakerIcon = GUIMediator.getThemeImage("speaker");

    text = new JLabel();
    Font f = new Font("DIALOG", Font.BOLD, 10);
    text.setFont(f);
    text.addMouseListener(new MouseAdapter() {
        @Override
        public void mousePressed(MouseEvent e) {
            if (MediaPlayer.instance().getCurrentSong().getFile() != null
                    || MediaPlayer.instance().getCurrentSong().getPlaylistItem() != null
                    || MediaPlayer.instance().getCurrentSong() instanceof InternetRadioAudioSource
                    || MediaPlayer.instance().getCurrentSong() instanceof DeviceAudioSource) {
                showCurrentSong();
            } else if (MediaPlayer.instance().getCurrentSong() instanceof StreamAudioSource) {
                StreamAudioSource audioSource = (StreamAudioSource) MediaPlayer.instance().getCurrentSong();
                if (audioSource.getDetailsUrl() != null) {
                    GUIMediator.openURL(audioSource.getDetailsUrl());
                }
            } else if (MediaPlayer.instance().getCurrentSong().getURL() != null) {
                GUIMediator.instance().setWindow(GUIMediator.Tabs.LIBRARY);
            }
        }
    });

    shareButton = new MediaButton(I18n.tr("Send this file to a friend"), "share", "share");
    shareButton.addActionListener(new SendToFriendActionListener());
    shareButton.setVisible(false);

    //Share Button
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = GridBagConstraints.RELATIVE;
    c.insets = new Insets(0, 0, 0, 3);
    add(shareButton, c);//, BorderLayout.LINE_END);

    //Go to Current Audio Control
    c.gridx = 0;
    c.gridx = 1;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.EAST;
    c.insets = new Insets(0, 0, 0, 0);
    add(text, c);//, BorderLayout.LINE_END);
}

From source file:org.pentaho.ui.xul.swing.tags.SwingDialog.java

public void resetContainer() {

    container.removeAll();//from www .j  av  a 2 s  .c om

    gc = new GridBagConstraints();
    gc.gridy = GridBagConstraints.RELATIVE;
    gc.gridx = 0;
    gc.gridheight = 1;
    gc.gridwidth = GridBagConstraints.REMAINDER;
    int pad = getPadding();
    gc.insets = new Insets(pad, pad, pad, pad);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weightx = 1;

}

From source file:com.intel.stl.ui.monitor.view.PSEventsPieChart.java

protected JPanel getLengendPanel() {
    JPanel panel = new JPanel();
    panel.setOpaque(false);//from  www  .  j  a  v  a2s .  c  o  m
    panel.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();

    gc.fill = GridBagConstraints.BOTH;
    StateLongTypeViz[] states = StateLongTypeViz.values();
    stateLabels = new JLabel[states.length];
    for (int i = 0; i < states.length; i++) {
        StateLongTypeViz state = states[i];
        gc.insets = new Insets(2, 5, 2, 2);
        gc.weightx = 0;
        gc.gridwidth = 1;

        JLabel label = new JLabel(state.getName(),
                Util.generateImageIcon(state.getColor(), 8, new Insets(1, 1, 1, 1)), JLabel.LEFT);
        label.setFont(UIConstants.H5_FONT);
        label.setForeground(UIConstants.INTEL_DARK_GRAY);
        panel.add(label, gc);

        gc.gridwidth = GridBagConstraints.REMAINDER;
        gc.weightx = 0;
        stateLabels[i] = new JLabel();
        stateLabels[i].setForeground(UIConstants.INTEL_DARK_GRAY);
        stateLabels[i].setFont(UIConstants.H5_FONT);
        panel.add(stateLabels[i], gc);
    }
    return panel;
}

From source file:savant.plugin.ToolSettingsPanel.java

private void addArgumentToPanel(ToolArgument arg, int row) {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(5, 5, 5, 5);
    gbc.gridy = row;/*  w  w w .  ja va  2  s.c o m*/
    JComponent widget = null;
    if (arg.type == ToolArgument.Type.BOOL) {
        gbc.gridx = 2;
        gbc.anchor = GridBagConstraints.WEST;
        addWidget(arg, new BoolCheck(arg), gbc);
    } else {
        gbc.gridx = 1;
        gbc.anchor = GridBagConstraints.EAST;
        JLabel nameLabel = new JLabel(arg.name + ":");
        add(nameLabel, gbc);

        gbc.gridx = 2;
        gbc.anchor = GridBagConstraints.WEST;
        gbc.gridwidth = GridBagConstraints.REMAINDER;
        gbc.weightx = 1.0;
        JTextField field = null;
        switch (arg.type) {
        case INT:
            field = new JFormattedTextField();
            ((JFormattedTextField) field).setValue(Integer.valueOf(arg.value != null ? arg.value : "0"));
            field.setColumns(5);
            addField(arg, field, gbc);
            break;
        case FLOAT:
            field = new JFormattedTextField();
            ((JFormattedTextField) field).setValue(Double.valueOf(arg.value != null ? arg.value : "0.0"));
            field.setColumns(10);
            addField(arg, field, gbc);
            break;
        case OUTPUT_FILE:
            gbc.gridwidth = 1;
            gbc.fill = GridBagConstraints.HORIZONTAL;
            field = new JTextField(arg.value);
            addField(arg, field, gbc);

            gbc.gridx = 3;
            gbc.gridwidth = GridBagConstraints.REMAINDER;
            gbc.weightx = 0.0;
            JCheckBox loadCheck = new JCheckBox("Load upon Completion", true);
            loadCheck.addActionListener(new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent ae) {
                    tool.loadUponCompletion = ((JCheckBox) ae.getSource()).isSelected();
                }
            });
            add(loadCheck, gbc);
            break;
        case RANGE:
            field = new JTextField();
            field.setColumns(25);
            LocationController.getInstance().addListener(new RangeUpdater(field));
            addField(arg, field, gbc);
            break;
        case LIST:
            addWidget(arg, new StringCombo(arg), gbc);
            break;
        case MULTI:
            gbc.fill = GridBagConstraints.HORIZONTAL;
            addWidget(arg, new MultiCheckGrid(arg), gbc);
            break;
        case BAM_INPUT_FILE:
            TrackUtils.addTrackListener(
                    (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.ALIGNMENT), gbc));
            break;
        case FASTA_INPUT_FILE:
            TrackUtils.addTrackListener(
                    (TrackCombo) addWidget(arg, new TrackCombo(arg, DataFormat.SEQUENCE), gbc));
            break;
        }
    }
}

From source file:org.pentaho.ui.xul.swing.tags.SwingGrid.java

@Override
public void layout() {

    if (this.getChildNodes().size() < 2) {
        logger.warn("Grid does not contain Column and Row children");
        return;//from  w ww .j a  va  2  s  . c  o  m
    }

    XulComponent columns = this.getChildNodes().get(0);
    XulComponent rows = this.getChildNodes().get(1);

    int colCount = 0;
    int rowCount = 0;
    float colFlexTotal = 0;
    float rowTotalFlex = 0;
    for (XulComponent col : columns.getChildNodes()) {
        if (col.getFlex() > 0) {
            colFlexTotal += col.getFlex();
        }
        colCount++;
    }

    for (XulComponent row : rows.getChildNodes()) {
        if (row.getFlex() > 0) {
            rowTotalFlex += row.getFlex();
        }
        rowCount++;
    }

    for (XulComponent row : rows.getChildNodes()) {
        gc.gridx = 0;

        for (XulComponent xulComp : row.getChildNodes()) {
            gc.weightx = 0.0;
            gc.gridwidth = 1;
            gc.gridheight = 1;
            gc.weighty = 0.0;
            gc.anchor = GridBagConstraints.NORTHWEST;
            gc.fill = GridBagConstraints.NONE;

            Component comp = (Component) xulComp.getManagedObject();
            float colFlex = columns.getChildNodes().get(gc.gridx).getFlex();
            int rowFlex = row.getFlex();

            Align colAlignment = null;
            Align rowAlignment = null;
            String colAlignmentStr = xulComp.getAlign();
            String rowAlignStr = row.getAlign();
            if (colAlignmentStr != null) {
                colAlignment = Align.valueOf(colAlignmentStr);
            }
            if (rowAlignStr != null) {
                rowAlignment = Align.valueOf(rowAlignStr);
            }

            if (colFlex > 0) {
                gc.weightx = (colFlex / colFlexTotal);
            }
            if (rowFlex > 0) {
                gc.weighty = (rowFlex / rowTotalFlex);
            }
            if (colAlignment == Align.STRETCH && xulComp.getFlex() > 0) {
                gc.fill = GridBagConstraints.BOTH;
            } else if (colAlignment == Align.STRETCH) {
                gc.fill = GridBagConstraints.HORIZONTAL;
            } else if (xulComp.getFlex() > 0) {
                gc.fill = GridBagConstraints.VERTICAL;
            }

            if (row.getChildNodes().indexOf(xulComp) + 1 == row.getChildNodes().size()) {
                gc.gridwidth = GridBagConstraints.REMAINDER;
            } else {
                gc.gridwidth = 1;
            }
            if (rows.getChildNodes().indexOf(row) + 1 == rows.getChildNodes().size()) {
                gc.gridheight = GridBagConstraints.REMAINDER;
            } else {
                gc.gridheight = 1;
            }

            // gc.gridheight = row.getFlex() + 1;

            if (colAlignment != null && rowAlignment != null) {
                switch (rowAlignment) {
                case START:
                    switch (colAlignment) {
                    case START:
                        gc.anchor = GridBagConstraints.NORTHWEST;
                        break;
                    case CENTER:
                        gc.anchor = GridBagConstraints.NORTH;
                        break;
                    case END:
                        gc.anchor = GridBagConstraints.NORTHEAST;
                        break;
                    }
                    break;
                case CENTER:
                    switch (colAlignment) {
                    case START:
                        gc.anchor = GridBagConstraints.WEST;
                        break;
                    case CENTER:
                        gc.anchor = GridBagConstraints.CENTER;
                        break;
                    case END:
                        gc.anchor = GridBagConstraints.EAST;
                        break;
                    }
                    break;
                case END:
                    switch (colAlignment) {
                    case START:
                        gc.anchor = GridBagConstraints.SOUTHWEST;
                        break;
                    case CENTER:
                        gc.anchor = GridBagConstraints.SOUTH;
                        break;
                    case END:
                        gc.anchor = GridBagConstraints.SOUTHEAST;
                        break;
                    }
                }
            } else if (rowAlignment != null) {
                switch (rowAlignment) {
                case START:
                    gc.anchor = GridBagConstraints.NORTHWEST;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.WEST;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.SOUTHWEST;
                    break;
                }
            } else if (colAlignment != null) {

                switch (colAlignment) {
                case START:
                    gc.anchor = GridBagConstraints.NORTHWEST;
                    break;
                case CENTER:
                    gc.anchor = GridBagConstraints.NORTH;
                    break;
                case END:
                    gc.anchor = GridBagConstraints.NORTHEAST;
                    break;
                }
            }

            if (comp.getWidth() > 0 || comp.getHeight() > 0) {
                Dimension minSize = comp.getMinimumSize();
                Dimension prefSize = comp.getPreferredSize();

                if (comp.getWidth() > 0) {
                    minSize.width = comp.getWidth();
                    prefSize.width = comp.getWidth();
                }
                if (comp.getHeight() > 0) {
                    minSize.height = comp.getHeight();
                    prefSize.height = comp.getHeight();
                }
                comp.setMinimumSize(minSize);
                comp.setPreferredSize(prefSize);
            } else {
                comp.setPreferredSize(comp.getMinimumSize());
            }

            grid.add(comp, gc);
            gc.gridx++;
        }

        gc.gridy++;
    }

    if (rowTotalFlex == 0) {
        // Add in an extra row at the bottom to push others up
        gc.gridy++;
        gc.weighty = 1;
        gc.fill = gc.REMAINDER;
        grid.add(Box.createGlue(), gc);
    }
    this.initialized = true;
}

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 w  w w  .  ja  v  a 2s. co  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);

}