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:org.tranche.gui.user.SignInPanel.java

public SignInPanel() {
    setBackground(Styles.COLOR_PANEL_BACKGROUND);
    setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.gridwidth = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(7, 7, 0, 0);
    gbc.weightx = 0;//from   w  w  w. ja  va2  s .c  om
    gbc.weighty = 1;
    add(new GenericLabel("Unique Name / Email:"), gbc);

    userNameTextField.addActionListener(this);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(7, 7, 0, 7);
    gbc.weightx = 1;
    add(userNameTextField, gbc);

    gbc.gridwidth = GridBagConstraints.RELATIVE;
    gbc.insets = new Insets(7, 7, 0, 0);
    gbc.weightx = 0;
    add(new GenericLabel("Password:"), gbc);

    passwordField.addActionListener(this);
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(7, 7, 0, 7);
    gbc.weightx = 1;
    add(passwordField, gbc);

    GenericRoundedButton signInButton = new GenericRoundedButton("Sign In");
    signInButton.addActionListener(this);
    gbc.insets = new Insets(7, 7, 7, 7);
    add(signInButton, gbc);

    if (ConfigureTranche.get(ConfigureTranche.CATEGORY_GENERAL, ConfigureTranche.PROP_SIGN_UP_URL) != null
            && !ConfigureTranche.get(ConfigureTranche.CATEGORY_GENERAL, ConfigureTranche.PROP_SIGN_UP_URL)
                    .equals("")) {
        JLabel noAccountLabel = new GenericLabel("No Account?");
        noAccountLabel.setFont(Styles.FONT_14PT_BOLD);
        gbc.insets = new Insets(10, 7, 0, 7);
        add(noAccountLabel, gbc);

        GenericRoundedButton applyButton = new GenericRoundedButton("Apply For An Account");
        applyButton.addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent e) {
                Thread t = new Thread() {

                    @Override()
                    public void run() {
                        GUIUtil.displayURL(ConfigureTranche.get(ConfigureTranche.CATEGORY_GENERAL,
                                ConfigureTranche.PROP_SIGN_UP_URL));
                    }
                };
                t.setDaemon(true);
                t.start();
            }
        });
        gbc.insets = new Insets(7, 7, 0, 7);
        add(applyButton, gbc);
    }

    JLabel userCertLabel = new GenericLabel("Have a User File?");
    userCertLabel.setFont(Styles.FONT_14PT_BOLD);
    gbc.insets = new Insets(10, 7, 0, 7);
    add(userCertLabel, gbc);

    GenericRoundedButton logInWithCertButton = new GenericRoundedButton("Sign In With My User Certificate");
    logInWithCertButton.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            final JFileChooser jfc = GUIUtil.makeNewFileChooser();
            Thread t = new Thread() {

                @Override
                public void run() {
                    UserZipFile uzf = null;
                    try {
                        uzf = GUIUtil.promptForUserFile(jfc, SignInPanel.this);
                    } catch (Exception e) {
                        ef.show(e, SignInPanel.this);
                    }
                    if (uzf != null) {
                        abq.offer(uzf);
                    }
                }
            };
            t.setDaemon(true);
            t.start();
        }
    });
    gbc.insets = new Insets(7, 7, 7, 7);
    add(logInWithCertButton, gbc);
}

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

public void resetContainer() {

    container.removeAll();/*from   ww w  . jav  a2 s. c  o  m*/

    gc = new GridBagConstraints();
    gc.gridx = GridBagConstraints.RELATIVE;
    gc.gridy = 0;
    gc.gridheight = GridBagConstraints.REMAINDER;
    gc.gridwidth = 1;

    int pad = getPadding();
    gc.insets = new Insets(pad, pad, pad, pad);
    gc.fill = GridBagConstraints.HORIZONTAL;
    gc.anchor = GridBagConstraints.NORTHWEST;
    gc.weighty = 1;

}

From source file:savant.settings.Section.java

public GridBagConstraints getFullRowConstraints() {
    return new GridBagConstraints(0, GridBagConstraints.RELATIVE, GridBagConstraints.REMAINDER, 1, 1.0, 0.0,
            GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(3, 3, 3, 3), 0, 0);
}

From source file:ProgressDialog.java

private void setupComponent() {

    JPanel contentPane = (JPanel) getContentPane();
    contentPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    contentPane.setLayout(new GridBagLayout());
    GridBagConstraints gc = new GridBagConstraints();
    gc.gridx = 0;/*from   w w w  . j  av  a 2s  .  com*/
    gc.gridy = GridBagConstraints.RELATIVE;
    gc.anchor = GridBagConstraints.NORTHWEST;
    contentPane.add(lblMessage, gc);
    gc.weightx = 1;
    gc.fill = GridBagConstraints.HORIZONTAL;
    contentPane.add(progressBar, gc);

    setTitle("");
    setModal(true);
    pack();

}

From source file:gate.creole.kea.CorpusImporter.java

protected void initGUIComponents() {
    setLayout(new GridBagLayout());
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridy = 0;// w ww . jav  a2s  .co  m
    constraints.gridx = GridBagConstraints.RELATIVE;
    constraints.weightx = 0;
    constraints.weighty = 0;
    constraints.fill = GridBagConstraints.BOTH;

    JPanel inputPanel = new JPanel(new GridBagLayout());
    inputPanel.setBorder(BorderFactory.createTitledBorder("Input"));
    GridBagConstraints constraints2 = new GridBagConstraints();
    constraints2.gridy = 0;
    constraints2.gridx = GridBagConstraints.RELATIVE;
    constraints2.weighty = 0;
    constraints2.weightx = 0;
    constraints2.fill = GridBagConstraints.BOTH;
    constraints2.insets = new Insets(2, 2, 2, 2);

    JLabel label = new JLabel("Source directory:");
    inputPanel.add(label, constraints2);
    sourceDirTField = new JTextField(30);
    inputPanel.add(sourceDirTField, constraints2);
    JButton openButton = new JButton(new SelectDirectoryAction());
    inputPanel.add(openButton, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Extension for text files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    textExtensionTField = new JTextField(".txt");
    inputPanel.add(textExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 2;
    label = new JLabel("Extension for keyphrase files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    keyExtensionTField = new JTextField(".key");
    inputPanel.add(keyExtensionTField, constraints2);
    constraints2.gridwidth = 1;

    constraints2.gridy = 3;
    label = new JLabel("Encoding for input files:");
    inputPanel.add(label, constraints2);
    constraints2.gridwidth = 2;
    encodingTField = new JTextField("");
    inputPanel.add(encodingTField, constraints2);
    constraints2.gridwidth = 1;

    add(inputPanel, constraints);
    constraints.weightx = 1;
    add(Box.createHorizontalGlue(), constraints);
    constraints.weightx = 0;

    JPanel outputPanel = new JPanel();
    outputPanel.setLayout(new GridBagLayout());
    outputPanel.setBorder(BorderFactory.createTitledBorder("Output"));

    constraints2.gridy = 0;
    label = new JLabel("Corpus name:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    corpusNameTField = new JTextField("KEA Corpus");
    constraints2.weightx = 0;
    outputPanel.add(corpusNameTField, constraints2);

    constraints2.gridy = 1;
    label = new JLabel("Output annotation set:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationSetTField = new JTextField("Key");
    constraints2.weightx = 0;
    outputPanel.add(annotationSetTField, constraints2);

    constraints2.gridy = 2;
    label = new JLabel("Keyphrase annotation type:");
    outputPanel.add(label, constraints2);
    constraints2.weightx = 1;
    annotationTypeTField = new JTextField("Keyphrase");
    constraints2.weightx = 0;
    outputPanel.add(annotationTypeTField, constraints2);

    constraints.gridy = 1;
    add(outputPanel, constraints);

    constraints.gridy = 2;
    constraints.fill = GridBagConstraints.NONE;
    constraints.anchor = GridBagConstraints.CENTER;
    add(new JButton(new ImportCorpusAction()), constraints);

    constraints.gridy = 3;
    constraints.weighty = 1;
    add(Box.createVerticalGlue(), constraints);
}

From source file:Composite.java

public void init() {
    GridBagLayout layOut = new GridBagLayout();
    getContentPane().setLayout(layOut);//from   ww w  .java  2  s .com

    GridBagConstraints l = new GridBagConstraints();
    l.weightx = 1.0;
    l.fill = GridBagConstraints.BOTH;
    l.gridwidth = GridBagConstraints.RELATIVE;
    alphaLabel = new JLabel();
    alphaLabel.setText("Alphas");
    Font newFont = getFont().deriveFont(1);
    alphaLabel.setFont(newFont);
    alphaLabel.setHorizontalAlignment(JLabel.CENTER);
    layOut.setConstraints(alphaLabel, l);
    getContentPane().add(alphaLabel);
    GridBagConstraints c = new GridBagConstraints();
    getContentPane().setLayout(layOut);

    l.gridwidth = GridBagConstraints.REMAINDER;
    rulesLabel = new JLabel();
    rulesLabel.setText("Rules");
    newFont = getFont().deriveFont(1);
    rulesLabel.setFont(newFont);
    rulesLabel.setHorizontalAlignment(JLabel.CENTER);
    layOut.setConstraints(rulesLabel, l);
    getContentPane().add(rulesLabel);

    GridBagConstraints a = new GridBagConstraints();
    a.gridwidth = GridBagConstraints.RELATIVE;
    a.weightx = 1.0;
    a.fill = GridBagConstraints.BOTH;
    alphas = new JComboBox();
    layOut.setConstraints(alphas, a);
    alphas.addItem("1.0");
    alphas.addItem("0.75");
    alphas.addItem("0.50");
    alphas.addItem("0.25");
    alphas.addItem("0.0");
    alphas.addItemListener(this);
    getContentPane().add(alphas);

    a.gridwidth = GridBagConstraints.REMAINDER;
    rules = new JComboBox();
    layOut.setConstraints(rules, a);
    rules.addItem("SRC");
    rules.addItem("DST_IN");
    rules.addItem("DST_OUT");
    rules.addItem("DST_OVER");
    rules.addItem("SRC_IN");
    rules.addItem("SRC_OVER");
    rules.addItem("SRC_OUT");
    rules.addItem("CLEAR");
    rules.addItemListener(this);
    getContentPane().add(rules);

    GridBagConstraints fC = new GridBagConstraints();
    fC.fill = GridBagConstraints.BOTH;
    fC.weightx = 1.0;
    fC.weighty = 1.0;
    fC.gridwidth = GridBagConstraints.REMAINDER;
    comp = new CompPanel();
    layOut.setConstraints(comp, fC);
    getContentPane().add(comp);

    validate();
}

From source file:fi.elfcloud.client.dialog.ModifyDataItemDialog.java

public ModifyDataItemDialog(JFrame parent, HashMap<String, String> metaMap, String diName) {
    super(parent, true);
    setTitle(Messages.getString("ModifyDataItemDialog.window_title") + diName); //$NON-NLS-1$
    this.metamap = metaMap;
    tagVector = new Vector<String>();
    setLocationRelativeTo(parent);/*www . ja va 2 s . c  om*/
    panel.setLayout(new GridBagLayout());
    GridBagConstraints cs = new GridBagConstraints();
    cs.insets = new Insets(0, 0, 5, 0);

    lblName = new JLabel(Messages.getString("ModifyDataItemDialog.label_name")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 0;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.gridwidth = 1;
    cs.weightx = 0;
    panel.add(lblName, cs);

    name = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 0;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.gridwidth = 2;
    cs.weightx = 1.0;
    name.setText(diName);
    panel.add(name, cs);

    lblDescription = new JLabel(Messages.getString("ModifyDataItemDialog.label_description")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 1;
    cs.gridwidth = 1;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 0;
    panel.add(lblDescription, cs);

    description = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 1;
    cs.gridwidth = 2;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 1.0;
    description.setText(metaMap.get("DSC")); //$NON-NLS-1$
    panel.add(description, cs);

    lblTags = new JLabel(Messages.getString("ModifyDataItemDialog.label_tags")); //$NON-NLS-1$
    cs.gridx = 0;
    cs.gridy = 2;
    cs.gridwidth = 1;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 0;
    panel.add(lblTags, cs);

    tags = new JTextField(getWidth());
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 2;
    cs.fill = GridBagConstraints.HORIZONTAL;
    cs.weightx = 1.0;
    panel.add(tags, cs);

    JButton addButton = new JButton(Messages.getString("ModifyDataItemDialog.button_add_tag")); //$NON-NLS-1$
    cs.gridx = GridBagConstraints.RELATIVE;
    cs.gridy = 2;
    cs.gridwidth = 1;
    cs.weightx = 0;
    addButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            String tagText = tags.getText().trim();
            if (!tagText.equals("")) { //$NON-NLS-1$
                addTags(tagText);
            }
            tags.setText(""); //$NON-NLS-1$

            checkboxPanel.revalidate();
            checkboxPanel.repaint();
        }
    });
    panel.add(addButton, cs);

    checkboxPanel = new JPanel(new WrapLayout(FlowLayout.LEFT));
    checkboxPanel.setSize(new Dimension(320, 1));
    try {
        addTags(metamap.get("TGS")); //$NON-NLS-1$
    } catch (NullPointerException e) {
        // No existing tags
    }
    panel.setBorder(new EmptyBorder(5, 5, 0, 5));
    getContentPane().add(panel, BorderLayout.NORTH);
    scrollPane = new JScrollPane(checkboxPanel);
    scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scrollPane.setBorder(null);
    getContentPane().add(scrollPane, BorderLayout.CENTER);

    JButton generateButton = new JButton(Messages.getString("ModifyDataItemDialog.button_save")); //$NON-NLS-1$
    generateButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (tags.getText().length() > 0) {
                addTags(tags.getText());
            }
            answer = true;
            setVisible(false);
        }
    });
    JButton cancelButton = new JButton(Messages.getString("ModifyDataItemDialog.button_cancel")); //$NON-NLS-1$
    cancelButton.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent arg0) {
            answer = false;
            setVisible(false);
        }
    });
    JPanel bp = new JPanel();
    bp.add(generateButton);
    bp.add(cancelButton);
    getContentPane().add(bp, BorderLayout.PAGE_END);

    setMinimumSize(new Dimension(320, 350));
    pack();
}

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

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

    this.add(new JLabel("Vous allez gnrer le fichier result_2033B.pdf contenant le rsultat."), c);
    c.gridy++;/*w w  w .j  a  va2 s .c o  m*/
    try {
        this.add(new JLabel("Il se trouvera dans le dossier "
                + new File(TemplateNXProps.getInstance().getStringProperty("Location2033BPDF"))
                        .getCanonicalPath()),
                c);
    } catch (IOException e1) {
        e1.printStackTrace();
    }

    final JButton buttonFermer = new JButton("Fermer");
    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            ((JFrame) SwingUtilities.getRoot(ResultatPanel.this)).dispose();
        }
    });

    final JButton buttonOuvrir = new JButton("Ouvrir dossier");
    buttonOuvrir.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            final String file = TemplateNXProps.getInstance().getStringProperty("Location2033BPDF");
            File f = new File(file);
            FileUtils.browseFile(f);
        }
    });

    // FIXME impossible de gnrer si le fichier est ouvert
    final JButton buttonGenerer = new JButton("Gnrer");
    buttonGenerer.addActionListener(new ActionListener() {
        public void actionPerformed(final ActionEvent event) {
            final Map2033B map = new Map2033B(new JProgressBar());
            map.generateMap();
        }
    });

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(buttonOuvrir, c);

    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(buttonGenerer, c);
    c.weightx = 0;
    this.add(buttonFermer, c);
}

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

/**
 *
 *
 * @param parent/*from   ww w .  ja v a  2  s .  c  o m*/
 * @param tabs tabs
 *
 * @return
 */
public static boolean showOptionsDialog(Component parent, OptionsTab[] tabs) {
    final OptionsPanel opts = new OptionsPanel(tabs);
    opts.reset();

    JDialog d = null;
    Window w = (Window) SwingUtilities.getAncestorOfClass(Window.class, parent);

    if (w instanceof JDialog) {
        d = new JDialog((JDialog) w, "Options", true);
    } else if (w instanceof JFrame) {
        d = new JDialog((JFrame) w, "Options", true);
    } else {
        d = new JDialog((JFrame) null, "Options", true);
    }

    final JDialog dialog = d;

    //  Create the bottom button panel
    final JButton cancel = new JButton("Cancel");
    cancel.setMnemonic('c');
    cancel.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            opts.cancelled = true;
            dialog.setVisible(false);
        }
    });

    final JButton ok = new JButton("Ok");
    ok.setMnemonic('o');
    ok.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (opts.validateTabs()) {
                dialog.setVisible(false);
            }
        }
    });
    dialog.getRootPane().setDefaultButton(ok);

    JPanel buttonPanel = new JPanel(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(6, 6, 0, 0);
    gbc.weighty = 1.0;
    UIUtil.jGridBagAdd(buttonPanel, ok, gbc, GridBagConstraints.RELATIVE);
    UIUtil.jGridBagAdd(buttonPanel, cancel, gbc, GridBagConstraints.REMAINDER);

    JPanel southPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 0, 0));
    southPanel.add(buttonPanel);

    //
    JPanel mainPanel = new JPanel(new BorderLayout());
    mainPanel.setBorder(BorderFactory.createEmptyBorder(4, 4, 4, 4));
    mainPanel.add(opts, BorderLayout.CENTER);
    mainPanel.add(southPanel, BorderLayout.SOUTH);

    // Show the dialog
    dialog.getContentPane().setLayout(new GridLayout(1, 1));
    dialog.getContentPane().add(mainPanel);
    dialog.pack();
    dialog.setResizable(true);
    UIUtil.positionComponent(SwingConstants.CENTER, dialog);
    dialog.setVisible(true);

    if (!opts.cancelled) {
        opts.applyTabs();
    }

    return !opts.cancelled;
}

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

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

    this.add(new JLabel("Vous allez gnrer le fichier result_2033A.pdf contenant le bilan simplifi."), c);
    c.gridy++;/*from   www . ja  va2 s .  c o m*/
    try {
        this.add(new JLabel("Il se trouvera dans le dossier "
                + new File(TemplateNXProps.getInstance().getStringProperty("Location2033APDF"))
                        .getCanonicalPath()),
                c);
    } catch (IOException e1) {
        // TODO Auto-generated catch block
        e1.printStackTrace();
    }

    /*
     * PdfGenerator_2033A p = new PdfGenerator_2033A(); p.generateFrom(new
     * Map2033A().getMap2033A());
     */

    JButton buttonFermer = new JButton("Fermer");
    buttonFermer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            ((JFrame) SwingUtilities.getRoot(BilanPanel.this)).dispose();
        }
    });

    JButton buttonOuvrirDossier = new JButton("Ouvrir dossier");
    buttonOuvrirDossier.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            String file = TemplateNXProps.getInstance().getStringProperty("Location2033APDF");
            File f = new File(file);
            FileUtils.browseFile(f);
        };
    });

    // FIXME impossible de gnrer si le fichier est ouvert
    JButton buttonGenerer = new JButton("Gnrer");
    buttonGenerer.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {

            Map2033A map = new Map2033A(new JProgressBar());
            map.generateMap2033A();
        };
    });

    c.gridx = GridBagConstraints.RELATIVE;
    c.gridwidth = 1;
    c.weightx = 0;
    c.fill = GridBagConstraints.NONE;
    this.add(buttonOuvrirDossier, c);

    c.gridy++;
    c.anchor = GridBagConstraints.EAST;
    c.weightx = 1;
    buttonGenerer.setHorizontalAlignment(SwingConstants.RIGHT);
    this.add(buttonGenerer, c);
    c.weightx = 0;
    this.add(buttonFermer, c);
}