Example usage for java.awt GridBagConstraints GridBagConstraints

List of usage examples for java.awt GridBagConstraints GridBagConstraints

Introduction

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

Prototype

public GridBagConstraints() 

Source Link

Document

Creates a GridBagConstraint object with all of its fields set to their default value.

Usage

From source file:com.rapidminer.gui.new_plotter.gui.dialog.AddParallelLineDialog.java

/**
 * Setup the GUI.//from  w w w  .j  ava 2  s  . c o  m
 */
private void setupGUI() {
    JPanel mainPanel = new JPanel();
    this.setContentPane(mainPanel);

    // start layout
    mainPanel.setLayout(new GridBagLayout());
    GridBagConstraints gbc = new GridBagConstraints();

    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    horizontalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.label"));
    horizontalLineRadiobutton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.horizontal.tip"));
    horizontalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setHorizontalLineSelected();
        }
    });
    horizontalLineRadiobutton.setSelected(true);
    this.add(horizontalLineRadiobutton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.EAST;
    verticalLineRadiobutton = new JRadioButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.label"));
    verticalLineRadiobutton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.vertical.tip"));
    verticalLineRadiobutton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            setVerticalLineSelected();
        }
    });
    this.add(verticalLineRadiobutton, gbc);

    ButtonGroup group = new ButtonGroup();
    group.add(horizontalLineRadiobutton);
    group.add(verticalLineRadiobutton);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.fill = GridBagConstraints.BOTH;
    gbc.weightx = 1;
    gbc.gridwidth = 2;
    gbc.anchor = GridBagConstraints.CENTER;
    rangeAxisSelectionCombobox = new JComboBox();
    rangeAxisSelectionCombobox.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.range_axis_combobox.tip"));
    rangeAxisSelectionCombobox.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateYFieldValue();
        }
    });
    this.add(rangeAxisSelectionCombobox, gbc);

    gbc.gridx = 0;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.NONE;
    gbc.weightx = 1;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 2, 5);
    JLabel xLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.label"));
    this.add(xLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 2;
    gbc.insets = new Insets(2, 5, 2, 5);
    gbc.fill = GridBagConstraints.HORIZONTAL;
    xField = new JTextField();
    xField.setText(String.valueOf(x));
    xField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyYInput(input);
        }
    });
    xField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.width.tip"));
    xField.setEnabled(false);
    this.add(xField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.NONE;
    JLabel yLabel = new JLabel(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.label"));
    this.add(yLabel, gbc);

    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    yField = new JTextField();
    yField.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.height.tip"));
    yField.setText(String.valueOf(y));
    yField.setInputVerifier(new InputVerifier() {

        @Override
        public boolean verify(JComponent input) {
            return verifyXInput(input);
        }
    });
    this.add(yField, gbc);

    gbc.gridx = 0;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.NONE;
    gbc.insets = new Insets(10, 5, 0, 5);
    modifyLineButton = new JButton();
    modifyLineButton.setToolTipText(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.tip"));
    modifyLineButton.setIcon(SwingTools.createIcon(
            "16/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.modify_line.icon")));
    modifyLineButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            modifyLine();
        }
    });
    this.add(modifyLineButton, gbc);

    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.gridwidth = 2;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.insets = new Insets(15, 5, 5, 5);
    this.add(new JSeparator(), gbc);

    gbc.gridx = 0;
    gbc.gridy = 6;
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 5, 5, 5);
    okButton = new JButton(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.label"));
    okButton.setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.tip"));
    okButton.setIcon(SwingTools
            .createIcon("24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.icon")));
    okButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.ok.mne").toCharArray()[0]);
    okButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            boolean successful = addSpecifiedLine();
            // don't dispose dialog if not successful
            if (!successful) {
                return;
            }

            AddParallelLineDialog.this.dispose();
        }
    });
    okButton.addKeyListener(new KeyAdapter() {

        @Override
        public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ENTER) {
                okButton.doClick();
            }
        }
    });
    this.add(okButton, gbc);

    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    cancelButton = new JButton(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.label"));
    cancelButton
            .setToolTipText(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.tip"));
    cancelButton.setIcon(SwingTools.createIcon(
            "24/" + I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.icon")));
    cancelButton.setMnemonic(
            I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.cancel.mne").toCharArray()[0]);
    cancelButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            // cancel requested, close dialog
            AddParallelLineDialog.this.dispose();
        }
    });
    this.add(cancelButton, gbc);

    // misc settings
    this.setMinimumSize(new Dimension(300, 250));
    // center dialog
    this.setLocationRelativeTo(null);
    this.setTitle(I18N.getMessage(I18N.getGUIBundle(), "gui.action.add_parallel_line.title.label"));
    this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    this.setModal(true);

    this.addWindowListener(new WindowAdapter() {

        @Override
        public void windowActivated(WindowEvent e) {
            okButton.requestFocusInWindow();
        }
    });
}

From source file:com.polivoto.vistas.Charts.java

public void getHeader(JPanel header) {
    header.removeAll();/*from  ww w.  j a v  a 2 s .com*/
    GridBagConstraints gridBagConstraints;
    header.setLayout(new GridBagLayout());
    header.setBackground(Color.white);
    header.setPreferredSize(new Dimension(0, 100));
    JLabel titulo = new JLabel("<html>     <b>Votacin: </b>" + votacion.getTitulo() + "</html>");
    JLabel lugar = new JLabel("<html>     <b>Lugar: </b>" + votacion.getLugar() + "</html>");
    SimpleDateFormat sdf = new SimpleDateFormat("EEEE d' de 'MMMM' del 'yyyy, hh:mm:ss");
    JLabel fechaInicio = new JLabel(
            "<html><b>Fecha de inicio: </b>" + sdf.format(new Date(votacion.getFechaInicio())) + "</html>");
    JLabel fechaFin = new JLabel(
            "<html><b>Fecha de fin: </b>" + sdf.format(new Date(votacion.getFechaFin())) + "</html>");
    titulo.setFont(fuenteNormal);
    titulo.setVerticalAlignment(JLabel.CENTER);
    lugar.setFont(fuenteNormal);
    lugar.setVerticalAlignment(JLabel.CENTER);
    fechaFin.setFont(fuenteNormal);
    fechaFin.setVerticalAlignment(JLabel.CENTER);
    fechaInicio.setFont(fuenteNormal);
    fechaInicio.setVerticalAlignment(JLabel.CENTER);
    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
    header.add(titulo, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 1;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15);
    header.add(fechaInicio, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 15, 5, 5);
    header.add(lugar, gridBagConstraints);

    gridBagConstraints = new GridBagConstraints();
    gridBagConstraints.gridx = 3;
    gridBagConstraints.gridy = 3;
    gridBagConstraints.fill = GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 0.1;
    gridBagConstraints.weighty = 0.1;
    gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 15);
    header.add(fechaFin, gridBagConstraints);

    header.repaint();
    header.revalidate();

}

From source file:com.att.aro.ui.view.menu.datacollector.DeviceDialogOptions.java

private void setUpLayoutProperties() {
    contentLayout = new GridBagLayout();

    labelConstraints = new GridBagConstraints();
    labelConstraints.fill = GridBagConstraints.BOTH;
    labelConstraints.weightx = 0.3;/*from  w w  w .  ja va 2  s  . c  o m*/
    labelConstraints.gridwidth = GridBagConstraints.RELATIVE;

    optionConstraints = new GridBagConstraints();
    optionConstraints.fill = GridBagConstraints.BOTH;
    optionConstraints.weightx = 1.0;
    optionConstraints.gridwidth = GridBagConstraints.REMAINDER;
}

From source file:gov.loc.repository.bagger.ui.NewBagInPlaceFrame.java

private void layoutSelectDataContent(JPanel contentPanel, int row) {
    GridBagConstraints glbc = new GridBagConstraints();
    JLabel location = new JLabel("Select Data:");
    saveAsButton = new JButton(bagView.getPropertyMessage("bag.button.browse"));
    saveAsButton.addActionListener(new BrowseFileHandler());
    saveAsButton.setEnabled(true);/*from ww w  . j a  va  2 s .  c o  m*/
    saveAsButton.setToolTipText(bagView.getPropertyMessage("bag.button.browse.help"));

    String fileName = "";
    if (bag != null)
        fileName = bag.getName();
    bagNameField = new JTextField(fileName);
    bagNameField.setCaretPosition(fileName.length());
    bagNameField.setEditable(false);
    bagNameField.setEnabled(false);

    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.WEST);
    contentPanel.add(location, glbc);

    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 1, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    glbc.ipadx = 5;
    glbc.ipadx = 0;
    contentPanel.add(saveAsButton, glbc);

    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 80, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    glbc.ipadx = 5;
    glbc.ipadx = 0;
    contentPanel.add(bagNameField, glbc);
}

From source file:com.game.ui.views.CharacterEditor.java

/**
 * This method draws up the gui on the panel.
 *//*from   ww w  .  j a v a 2  s  . c om*/
public void doGui() {
    JPanel outerPane = new JPanel();
    outerPane.setLayout(new GridBagLayout());
    //        setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(lblContent);
    noteLbl.setAlignmentX(0);
    GridBagConstraints c = new GridBagConstraints();
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.NONE;
    c.insets = new Insets(5, 5, 5, 5);
    c.gridwidth = 4;
    c.gridy = 0;
    c.gridx = 0;
    outerPane.add(noteLbl, c);
    System.out.println(c.gridy);
    c.gridy++;
    System.out.println(c.gridy);
    c.gridx = 0;
    c.gridwidth = 1;
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    outerPane.add(comboBox, c);
    c.gridy++;
    JLabel nameLbl = new JLabel("Name : ");
    outerPane.add(nameLbl, c);
    c.gridx++;
    name = new JTextField();
    name.setColumns(20);
    outerPane.add(name, c);
    c.gridx = 0;
    c.gridy++;
    JLabel imageLbl = new JLabel("Image Path : ");
    outerPane.add(imageLbl, c);
    c.gridx++;
    imgPath = new JTextField();
    imgPath.setColumns(20);
    outerPane.add(imgPath, c);
    c.gridx = 0;
    c.gridy++;
    JLabel hitPtsLbl = new JLabel("Hit Points : ");
    outerPane.add(hitPtsLbl, c);
    c.gridx++;
    hitPoints = new JTextField();
    hitPoints.setColumns(20);
    outerPane.add(hitPoints, c);
    c.gridx = 0;
    c.gridy++;
    JLabel lvl = new JLabel("Level : ");
    outerPane.add(lvl, c);
    c.gridx++;
    level = new JTextField();
    level.setColumns(20);
    /*if(!isEnemy){
    level.setText("1");
    level.setEnabled(false);
    }*/
    outerPane.add(level, c);
    c.gridx = 0;
    c.gridy++;
    JLabel mlWpn = new JLabel("Melee Weapon : ");
    outerPane.add(mlWpn, c);
    c.gridx++;
    model = new DefaultComboBoxModel();
    LinkedList<String> meleeWpnList = new LinkedList<String>();
    LinkedList<String> rngdWpnList = new LinkedList<String>();
    for (Item item : GameBean.weaponDetails) {
        Weapon wpn = (Weapon) item;
        if (wpn.getWeaponType().equalsIgnoreCase(Configuration.weaponTypes[0])) {
            meleeWpnList.add(wpn.getName());
        } else {
            rngdWpnList.add(wpn.getName());
        }
        weaponMap.put(wpn.getName(), wpn);
    }
    meleeWeapon = new JComboBox(new DefaultComboBoxModel(meleeWpnList.toArray()));
    meleeWeapon.setSelectedIndex(-1);
    meleeWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(meleeWeapon, c);
    c.gridx++;
    JLabel rngdWpn = new JLabel("Ranged Weapon : ");
    outerPane.add(rngdWpn, c);
    c.gridx++;
    rangedWeapon = new JComboBox(new DefaultComboBoxModel(rngdWpnList.toArray()));
    rangedWeapon.setSelectedIndex(-1);
    rangedWeapon.setMaximumSize(new Dimension(100, 30));
    outerPane.add(rangedWeapon, c);
    c.gridy++;
    c.gridx = 0;
    JLabel armourLbl = new JLabel("Armour : ");
    outerPane.add(armourLbl, c);
    c.gridx++;
    LinkedList<String> armourList = new LinkedList<String>();
    LinkedList<String> shildList = new LinkedList<String>();
    for (Item item : GameBean.armourDetails) {
        Armour temp = (Armour) item;
        if (temp.getArmourType() != null) {
            if (temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[1])) {
                armourList.add(temp.getName());
            } else {
                shildList.add(temp.getName());
            }
        } else {
            armourList.add(temp.getName());
            //            else if(temp.getArmourType().equalsIgnoreCase(Configuration.armourTypes[2]))
            shildList.add(temp.getName());
        }
        armorMap.put(temp.getName(), temp);
    }
    armour = new JComboBox(new DefaultComboBoxModel(armourList.toArray()));
    armour.setSelectedIndex(-1);
    armour.setMaximumSize(new Dimension(100, 30));
    outerPane.add(armour, c);
    c.gridx++;
    JLabel shieldLbl = new JLabel("Shield : ");
    outerPane.add(shieldLbl, c);
    c.gridx++;
    shield = new JComboBox(new DefaultComboBoxModel(shildList.toArray()));
    shield.setSelectedIndex(-1);
    shield.setMaximumSize(new Dimension(100, 30));
    outerPane.add(shield, c);
    ta = new JTextArea(10, 50);
    ta.setRows(40);
    ta.setBorder(BorderFactory.createLineBorder(Color.LIGHT_GRAY));
    JScrollPane scrollPane = new JScrollPane(ta);
    scrollPane.setPreferredSize(new Dimension(600, 250));
    c.gridx = 0;
    c.gridy++;
    c.fill = GridBagConstraints.BOTH;
    c.gridwidth = 4;
    c.gridheight = 4;
    c.weightx = .5;
    c.weighty = 1;
    outerPane.add(scrollPane, c);
    c.gridy += 4;
    c.gridx = 0;
    c.weightx = 0;
    c.weighty = 0;
    c.fill = GridBagConstraints.NONE;
    c.gridheight = 1;
    c.gridwidth = 1;
    JButton generate = new JButton("Generate");
    JButton submit = new JButton("Submit");
    outerPane.add(generate, c);
    submit.addActionListener(this);
    generate.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent ae) {
            ta.setText("");
            HashSet<Integer> set = new HashSet<Integer>();
            int strength = getUniqueVal(set);
            int constitution = getUniqueVal(set);
            int dext = getUniqueVal(set);
            int intel = getUniqueVal(set);
            int charisma = getUniqueVal(set);
            int wisdom = getUniqueVal(set);
            if (character == null) {
                builder = new CharacterBuilder(isEnemy);
            } else {
                builder = new CharacterBuilder(character);
            }
            builder.setStrength(strength);
            builder.setConstitution(constitution);
            builder.setDexterity(dext);
            builder.setIntelligence(intel);
            builder.setCharisma(charisma);
            builder.setWisdom(wisdom);
            int strModifier = GameUtils.calculateAbilityModifier(strength);
            int conModifier = GameUtils.calculateAbilityModifier(constitution);
            int dexModifier = GameUtils.calculateAbilityModifier(dext);
            int wisModifier = GameUtils.calculateAbilityModifier(wisdom);
            int intModifier = GameUtils.calculateAbilityModifier(intel);
            int chaModifier = GameUtils.calculateAbilityModifier(charisma);
            builder.setStrengthModifier(strModifier);
            builder.setConstitutionModifier(conModifier);
            builder.setCharismaModifier(chaModifier);
            builder.setWisdomModifier(wisModifier);
            builder.setIntelligenceModifier(intModifier);
            builder.setDexterityModifier(dexModifier);
            String type = null;
            if (constitution < strength && constitution > dext) {
                type = "Bully";
                builder.setType("Bully");
            } else if (dext > constitution && constitution > strength) {
                builder.setType("Nimble");
                type = "Nimble";
            } else {
                builder.setType("Tank");
                type = "Tank";
            }
            ta.append("Strength : " + strength);
            ta.append("\nDexterity : " + dexModifier);
            ta.append("\nConstitution : " + constitution);
            ta.append("\nIntelligence : " + intel);
            ta.append("\nCharisma: " + charisma);
            ta.append("\nWisdom : " + wisdom);
            ta.append("\nType :" + type);
            ta.append("\nStrength Modifier :" + strModifier);
            ta.append("\nConstitution Modifier :" + conModifier);
            ta.append("\nDexterity Modifier :" + dexModifier);
            generated = true;
            if (character != null) {
                character = builder.build();
            }
        }
    });
    c.gridx++;
    outerPane.add(submit, c);
    validationMess = new JLabel();
    validationMess.setForeground(Color.red);
    //        validationMess.setVisible(false);
    c.gridy++;
    c.gridx = 0;
    c.gridwidth = 4;
    outerPane.add(validationMess, c);
    JScrollPane outerScrollPane = new JScrollPane(outerPane);
    setLayout(new BorderLayout());
    add(outerScrollPane, BorderLayout.CENTER);
}

From source file:com.sec.ose.osi.ui.frm.main.identification.autoidentify.JPanImportSPDX.java

private void updateImportSPDXList() {
    getJPanelImportSPDX().removeAll();//from  w w w  . ja  v a 2 s .  c  om
    int index = 0;
    for (index = 0; index < getJPanSPDXLocationList().size(); index++) {
        JPanLocation tmpLocation = getJPanSPDXLocationList().get(index);
        if (tmpLocation != null) {
            GridBagConstraints tmpGridBagConstraints = new GridBagConstraints();
            tmpGridBagConstraints.insets = new Insets(5, 5, 0, 5); //Insets(int top, int left, int bottom, int right) 
            tmpGridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
            tmpGridBagConstraints.gridx = 0;
            tmpGridBagConstraints.gridy = index;

            getJPanelImportSPDX().add(tmpLocation, tmpGridBagConstraints);
        }
    }

    GridBagConstraints tmpGridBagConstraints = new GridBagConstraints();
    tmpGridBagConstraints.fill = GridBagConstraints.BOTH;
    tmpGridBagConstraints.gridx = 0;
    tmpGridBagConstraints.gridy = index;
    tmpGridBagConstraints.weighty = 1.0;
    getJPanelImportSPDX().add(new JLabel(), tmpGridBagConstraints);

    checkValid();

    getJPanelImportSPDX().updateUI();
}

From source file:com.sec.ose.osi.ui.frm.main.identification.JPanIdentifyResetComment.java

private Component getJPanelOkResetBtn() {
    if (jPanOKCancelBtn == null) {

        jPanOKCancelBtn = new JPanel();

        GridBagConstraints gridBagConstraintsOKBtn = new GridBagConstraints();
        gridBagConstraintsOKBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsOKBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsOKBtn.gridx = 0;
        gridBagConstraintsOKBtn.gridy = 0;

        GridBagConstraints gridBagConstraintsResetBtn = new GridBagConstraints();
        gridBagConstraintsResetBtn.gridx = 0;
        gridBagConstraintsResetBtn.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraintsResetBtn.insets = new Insets(0, 0, 10, 0);
        gridBagConstraintsResetBtn.gridy = 1;

        jPanOKCancelBtn.setLayout(new GridBagLayout());
        jPanOKCancelBtn.add(getJButtonOK(), gridBagConstraintsOKBtn);
        jPanOKCancelBtn.add(getJButtonReset(), gridBagConstraintsResetBtn);
    }//  w  ww.  j  a va  2  s . c  o m
    return jPanOKCancelBtn;
}

From source file:TextSamplerDemo.java

public TextSamplerDemo() {
    setLayout(new BorderLayout());

    //Create a regular text field.
    JTextField textField = new JTextField(10);
    textField.setActionCommand(textFieldString);
    textField.addActionListener(this);

    //Create a password field.
    JPasswordField passwordField = new JPasswordField(10);
    passwordField.setActionCommand(passwordFieldString);
    passwordField.addActionListener(this);

    //Create a formatted text field.
    JFormattedTextField ftf = new JFormattedTextField(java.util.Calendar.getInstance().getTime());
    ftf.setActionCommand(textFieldString);
    ftf.addActionListener(this);

    //Create some labels for the fields.
    JLabel textFieldLabel = new JLabel(textFieldString + ": ");
    textFieldLabel.setLabelFor(textField);
    JLabel passwordFieldLabel = new JLabel(passwordFieldString + ": ");
    passwordFieldLabel.setLabelFor(passwordField);
    JLabel ftfLabel = new JLabel(ftfString + ": ");
    ftfLabel.setLabelFor(ftf);/*from   ww  w  .  jav a  2s.  c o  m*/

    //Create a label to put messages during an action event.
    actionLabel = new JLabel("Type text and then Enter in a field.");
    actionLabel.setBorder(BorderFactory.createEmptyBorder(10, 0, 0, 0));

    //Lay out the text controls and the labels.
    JPanel textControlsPane = new JPanel();
    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    textControlsPane.setLayout(gridbag);

    JLabel[] labels = { textFieldLabel, passwordFieldLabel, ftfLabel };
    JTextField[] textFields = { textField, passwordField, ftf };
    addLabelTextRows(labels, textFields, gridbag, textControlsPane);

    c.gridwidth = GridBagConstraints.REMAINDER; //last
    c.anchor = GridBagConstraints.WEST;
    c.weightx = 1.0;
    textControlsPane.add(actionLabel, c);
    textControlsPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createTitledBorder("Text Fields"), BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Create a text area.
    JTextArea textArea = new JTextArea("This is an editable JTextArea. "
            + "A text area is a \"plain\" text component, " + "which means that although it can display text "
            + "in any font, all of the text is in the same font.");
    textArea.setFont(new Font("Serif", Font.ITALIC, 16));
    textArea.setLineWrap(true);
    textArea.setWrapStyleWord(true);
    JScrollPane areaScrollPane = new JScrollPane(textArea);
    areaScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    areaScrollPane.setPreferredSize(new Dimension(250, 250));
    areaScrollPane.setBorder(BorderFactory.createCompoundBorder(
            BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Plain Text"),
                    BorderFactory.createEmptyBorder(5, 5, 5, 5)),
            areaScrollPane.getBorder()));

    //Create an editor pane.
    JEditorPane editorPane = createEditorPane();
    JScrollPane editorScrollPane = new JScrollPane(editorPane);
    editorScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    editorScrollPane.setPreferredSize(new Dimension(250, 145));
    editorScrollPane.setMinimumSize(new Dimension(10, 10));

    //Create a text pane.
    JTextPane textPane = createTextPane();
    JScrollPane paneScrollPane = new JScrollPane(textPane);
    paneScrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    paneScrollPane.setPreferredSize(new Dimension(250, 155));
    paneScrollPane.setMinimumSize(new Dimension(10, 10));

    //Put the editor pane and the text pane in a split pane.
    JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, editorScrollPane, paneScrollPane);
    splitPane.setOneTouchExpandable(true);
    splitPane.setResizeWeight(0.5);
    JPanel rightPane = new JPanel(new GridLayout(1, 0));
    rightPane.add(splitPane);
    rightPane.setBorder(BorderFactory.createCompoundBorder(BorderFactory.createTitledBorder("Styled Text"),
            BorderFactory.createEmptyBorder(5, 5, 5, 5)));

    //Put everything together.
    JPanel leftPane = new JPanel(new BorderLayout());
    leftPane.add(textControlsPane, BorderLayout.PAGE_START);
    leftPane.add(areaScrollPane, BorderLayout.CENTER);

    add(leftPane, BorderLayout.LINE_START);
    add(rightPane, BorderLayout.LINE_END);
}

From source file:coolmap.canvas.datarenderer.renderer.impl.NumberComposite.java

public NumberComposite() {

    setName("Number to Composite");
    //        System.out.println("Created a new NumberComposite");
    setDescription("A renderer that can be used to assign renderers to different aggregations");

    configUI.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridx = 0;/*from  w w w . ja  v  a 2 s .  co  m*/
    c.gridy = 0;
    c.ipadx = 5;
    c.ipady = 5;
    c.insets = new Insets(2, 2, 2, 2);
    c.gridwidth = 1;

    //This combo box will need to be able to add registered
    singleComboBox = new JComboBox();
    rowComboBox = new JComboBox();
    columnComboBox = new JComboBox();
    rowColumnComboBox = new JComboBox();

    singleLegend = new JLabel();
    rowLegend = new JLabel();
    columnLegend = new JLabel();
    rowColumnLegend = new JLabel();

    singleLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    columnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));
    rowColumnLegend.setBorder(BorderFactory.createEmptyBorder(0, 5, 0, 5));

    //Add them
    JLabel label = new JLabel("Default:");
    label.setToolTipText("Default renderer");
    c.gridx = 0;
    c.gridy++;
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(singleComboBox, c);
    singleComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 2;
    JButton config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (singleRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    singleRenderer.getConfigUI(), "Default Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(singleLegend, c);

    //////////////////////////////////////////////////////////////
    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row Group:");
    label.setToolTipText("Renderer for row ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowGroupRenderer.getConfigUI(), "Row Group Renderer Config", JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }

        }
    });
    rowComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowLegend, c);

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Column Group:");
    label.setToolTipText("Renderer for column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(columnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (columnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    columnGroupRenderer.getConfigUI(), "Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(columnLegend, c);
    columnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 1;
    label = new JLabel("Row & Column Group:");
    label.setToolTipText("Renderer for row and column ontology nodes");
    configUI.add(label, c);
    c.gridx = 1;
    configUI.add(rowColumnComboBox, c);
    c.gridx++;
    config = new JButton(UI.getImageIcon("gear"));
    configUI.add(config, c);
    config.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            if (rowColumnGroupRenderer == null) {
                return;
            }
            //                JOptionPane.showmess
            int returnVal = JOptionPane.showConfirmDialog(CoolMapMaster.getCMainFrame(),
                    rowColumnGroupRenderer.getConfigUI(), "Row + Column Group Renderer Config",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null);
            if (returnVal == JOptionPane.OK_OPTION) {
                updateRenderer();
            }
        }
    });
    rowColumnComboBox.addItemListener(new ItemListener() {

        @Override
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                updateRenderer();
            }
        }
    });

    c.gridx = 1;
    c.gridy++;
    c.gridwidth = 1;
    configUI.add(rowColumnLegend, c);

    JButton button = new JButton("Apply Changes", UI.getImageIcon("refresh"));
    button.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            updateRenderer();
        }
    });

    c.gridx = 0;
    c.gridy++;
    c.gridwidth = 2;
    configUI.add(button, c);

    singleComboBox.setRenderer(new ComboRenderer());
    rowComboBox.setRenderer(new ComboRenderer());
    columnComboBox.setRenderer(new ComboRenderer());
    rowColumnComboBox.setRenderer(new ComboRenderer());

    _updateLists();

}

From source file:edu.harvard.mcz.imagecapture.RunnableJobReportDialog.java

/**
 * This method initializes jPanel   //from  w  ww .  j  a va  2 s .c o  m
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.BOTH;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        gridBagConstraints.gridheight = 3;
        gridBagConstraints.gridx = 0;
        jLabel = new JLabel();
        jLabel.setText(title);
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(jLabel, new GridBagConstraints());
        jPanel.add(getJTextArea(), gridBagConstraints);
    }
    return jPanel;
}