Example usage for java.awt GridBagConstraints WEST

List of usage examples for java.awt GridBagConstraints WEST

Introduction

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

Prototype

int WEST

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

Click Source Link

Document

Put the component on the left side of its display area, centered vertically.

Usage

From source file:com.digitalgeneralists.assurance.ui.components.ScanHistoryPanel.java

private void initializeComponent() {
    if (!this.initialized) {
        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        GridBagConstraints existingScansPanelConstraints = new GridBagConstraints();
        existingScansPanelConstraints.anchor = GridBagConstraints.WEST;
        existingScansPanelConstraints.fill = GridBagConstraints.BOTH;
        existingScansPanelConstraints.gridx = 0;
        existingScansPanelConstraints.gridy = 0;
        existingScansPanelConstraints.weightx = 1.0;
        existingScansPanelConstraints.weighty = 1.0;
        existingScansPanelConstraints.gridheight = 1;
        existingScansPanelConstraints.gridwidth = 1;
        existingScansPanelConstraints.insets = new Insets(0, 0, 0, 0);

        this.existingScansListPanel = new ListInputPanel<Scan>(this, this, true, true);
        this.add(this.existingScansListPanel, existingScansPanelConstraints);

        this.addAncestorListener(new AncestorListener() {
            public void ancestorAdded(AncestorEvent event) {
                applicationDelegate.addEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScansLoadedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.addEventObserver(ScanDeletedEvent.class,
                        (IEventObserver) event.getSource());

                applicationDelegate.loadScans();
            }/*from  w w  w  . jav  a  2 s. co  m*/

            public void ancestorRemoved(AncestorEvent event) {
                applicationDelegate.removeEventObserver(ScanCompletedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScansLoadedEvent.class,
                        (IEventObserver) event.getSource());
                applicationDelegate.removeEventObserver(ScanDeletedEvent.class,
                        (IEventObserver) event.getSource());
            }

            public void ancestorMoved(AncestorEvent event) {
            }
        });

        this.initialized = true;
    }
}

From source file:com.codedx.burp.security.InvalidCertificateDialogStrategy.java

@Override
public CertificateAcceptance checkAcceptance(Certificate genericCert, CertificateException certError) {
    if (genericCert instanceof X509Certificate && defaultHostVerifier instanceof DefaultHostnameVerifier) {
        X509Certificate cert = (X509Certificate) genericCert;
        DefaultHostnameVerifier verifier = (DefaultHostnameVerifier) defaultHostVerifier;

        JPanel message = new JPanel(new GridBagLayout());
        GridBagConstraints gbc = new GridBagConstraints();
        gbc.gridwidth = 2;/* ww  w.j av  a 2  s.co  m*/
        gbc.insets = new Insets(0, 0, 10, 0);
        gbc.anchor = GridBagConstraints.WEST;
        message.add(
                new JLabel("Unable to establish a secure connection because the certificate is not trusted"),
                gbc);

        gbc = new GridBagConstraints();
        gbc.gridy = 2;
        gbc.insets = new Insets(2, 0, 2, 0);
        gbc.anchor = GridBagConstraints.WEST;

        JLabel issuer = new JLabel("Issuer: ");
        Font defaultFont = issuer.getFont();
        Font bold = new Font(defaultFont.getName(), Font.BOLD, defaultFont.getSize());
        issuer.setFont(bold);

        message.add(issuer, gbc);
        gbc.gridx = 1;
        message.add(new JLabel(cert.getIssuerDN().toString()), gbc);

        try {
            JLabel fingerprint = new JLabel("Thumbprint: ");
            fingerprint.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(fingerprint, gbc);

            gbc.gridx = 1;
            message.add(new JLabel(toHexString(getSHA1(cert.getEncoded()), " ")), gbc);
        } catch (CertificateEncodingException e) {
            // this shouldn't actually ever happen
        }

        try {
            verifier.verify(host, cert);
        } catch (SSLException e) {
            String cn = getCN(cert);

            JLabel mismatch = new JLabel("Host Mismatch: ");
            mismatch.setFont(bold);
            gbc.gridx = 0;
            gbc.gridy += 1;
            message.add(mismatch, gbc);

            String msg;
            if (cn != null) {
                msg = String.format("Expected '%s', but the certificate is for '%s'.", host, cn);
            } else {
                msg = e.getMessage();
            }

            gbc.gridx = 1;
            message.add(new JLabel(msg), gbc);
        }

        // Open the dialog, and return its result
        int choice = JOptionPane.showOptionDialog(burpExtender.getUiComponent(), message, dialogTitle,
                JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE, null, dialogButtons, null);
        switch (choice) {
        case (0):
            return CertificateAcceptance.REJECT;
        case (1):
            return CertificateAcceptance.ACCEPT_TEMPORARILY;
        case (2):
            return CertificateAcceptance.ACCEPT_PERMANENTLY;
        }
    }
    return CertificateAcceptance.REJECT;
}

From source file:EditorPaneExample10.java

public EditorPaneExample10() {
    super("JEditorPane Example 10");

    pane = new JEditorPane();
    pane.setEditable(false); // Read-only
    getContentPane().add(new JScrollPane(pane), "Center");

    // Build the panel of controls
    JPanel panel = new JPanel();

    panel.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.gridwidth = 1;//from w w  w . j  a  va2  s. c o  m
    c.gridheight = 1;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0.0;
    c.weighty = 0.0;

    JLabel urlLabel = new JLabel("URL: ", JLabel.RIGHT);
    panel.add(urlLabel, c);
    JLabel loadingLabel = new JLabel("State: ", JLabel.RIGHT);
    c.gridy = 1;
    panel.add(loadingLabel, c);
    JLabel typeLabel = new JLabel("Type: ", JLabel.RIGHT);
    c.gridy = 2;
    panel.add(typeLabel, c);
    c.gridy = 3;
    panel.add(new JLabel(LOAD_TIME), c);

    c.gridy = 4;
    c.gridwidth = 2;
    c.weightx = 1.0;
    c.anchor = GridBagConstraints.WEST;
    onlineLoad = new JCheckBox("Online Load");
    panel.add(onlineLoad, c);
    onlineLoad.setSelected(true);
    onlineLoad.setForeground(typeLabel.getForeground());

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.EAST;
    c.fill = GridBagConstraints.HORIZONTAL;

    urlCombo = new JComboBox();
    panel.add(urlCombo, c);
    urlCombo.setEditable(true);
    loadingState = new JLabel(spaces, JLabel.LEFT);
    loadingState.setForeground(Color.black);
    c.gridy = 1;
    panel.add(loadingState, c);
    loadedType = new JLabel(spaces, JLabel.LEFT);
    loadedType.setForeground(Color.black);
    c.gridy = 2;
    panel.add(loadedType, c);
    timeLabel = new JLabel("");
    c.gridy = 3;
    panel.add(timeLabel, c);

    getContentPane().add(panel, "South");

    // Change page based on combo selection
    urlCombo.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent evt) {
            if (populatingCombo == true) {
                return;
            }
            Object selection = urlCombo.getSelectedItem();
            try {
                // Check if the new page and the old
                // page are the same.
                URL url;
                if (selection instanceof URL) {
                    url = (URL) selection;
                } else {
                    url = new URL((String) selection);
                }

                URL loadedURL = pane.getPage();
                if (loadedURL != null && loadedURL.sameFile(url)) {
                    return;
                }

                // Try to display the page
                urlCombo.setEnabled(false); // Disable input
                urlCombo.paintImmediately(0, 0, urlCombo.getSize().width, urlCombo.getSize().height);
                setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
                // Busy cursor
                loadingState.setText("Loading...");
                loadingState.paintImmediately(0, 0, loadingState.getSize().width,
                        loadingState.getSize().height);
                loadedType.setText("");
                loadedType.paintImmediately(0, 0, loadedType.getSize().width, loadedType.getSize().height);

                timeLabel.setText("");
                timeLabel.paintImmediately(0, 0, timeLabel.getSize().width, timeLabel.getSize().height);

                startTime = System.currentTimeMillis();

                // Choose the loading method
                if (onlineLoad.isSelected()) {
                    // Usual load via setPage
                    pane.setPage(url);
                    loadedType.setText(pane.getContentType());
                } else {
                    pane.setContentType("text/html");
                    loadedType.setText(pane.getContentType());
                    if (loader == null) {
                        loader = new HTMLDocumentLoader();
                    }
                    HTMLDocument doc = loader.loadDocument(url);
                    loadComplete();
                    pane.setDocument(doc);
                    displayLoadTime();
                    populateCombo(findLinks(doc, null));
                    enableInput();
                }
            } catch (Exception e) {
                System.out.println(e);
                JOptionPane.showMessageDialog(pane,
                        new String[] { "Unable to open file", selection.toString() }, "File Open Error",
                        JOptionPane.ERROR_MESSAGE);
                loadingState.setText("Failed");
                enableInput();
            }
        }
    });

    // Listen for page load to complete
    pane.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if (evt.getPropertyName().equals("page")) {
                loadComplete();
                displayLoadTime();
                populateCombo(findLinks(pane.getDocument(), null));
                enableInput();
            }
        }
    });
}

From source file:Demo.HistGraph.java

public HistGraph(List<String> paraType_list) {
    this.paraType_list = paraType_list;

    // widgets: charts(JFreeChart), parameter selector (JList)
    chartPane = new ChartPanel(null);
    charts = new JFreeChart[paraType_list.size()];

    DefaultListModel modelOfList = new DefaultListModel();
    paraSelector = new JList(modelOfList);

    for (int i = 0; i < paraType_list.size(); i++) {
        modelOfList.addElement(paraType_list.get(i));
        charts[i] = null;//from   ww  w .  j ava 2 s  .  com
    }

    paraSelector.setSelectedIndex(0);

    charts[0] = CreateChart(paraType_list.get(0));
    chartPane.setChart(charts[0]);

    JScrollPane selectorPanel = new JScrollPane();
    selectorPanel.setViewportView(paraSelector);

    paraSelector.addMouseListener(this);

    // layout
    GridBagLayout layout = new GridBagLayout();
    setLayout(layout);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.fill = GridBagConstraints.BOTH;

    gbc.weighty = 1;
    gbc.anchor = GridBagConstraints.WEST;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.weightx = 20;
    add(new JLabel("Distribution:"), gbc);

    gbc.insets = new Insets(5, 5, 5, 20);
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.weightx = 1;
    add(new JLabel("Parameters:"), gbc);

    gbc.weighty = 14;

    gbc.insets = new Insets(5, 20, 5, 5);
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 20;
    add(chartPane, gbc);

    gbc.insets = new Insets(5, 5, 15, 20);
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 1;
    add(selectorPanel, gbc);
}

From source file:verdandi.ui.settings.DefaultSettingsPanel.java

private void initControls() {
    setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.gridx = c.gridy = 0;//from   w w w . j  a va2 s  .com
    c.weightx = 1.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.WEST;

    add(getMiscellaneousSettingsPanel(), c);
    c.gridy++;
    add(getTimeFormatSettingsPanel(), c);
    c.gridy++;
    workDaySettingsPanel = new WorkDaySettingsPanel();
    add(workDaySettingsPanel, c);
    c.gridy++;
    add(getAnnotatedWorkRecordViewPrefs(), c);
    c.gridy++;
    add(getPersistenceSettingsPanel(), c);
}

From source file:geneon.intellij.plugin.jenkins.ui.EditServerDialog.java

@Nullable
@Override/*w  w w  .  jav a 2  s.  c  om*/
protected JComponent createCenterPanel() {
    nameTextField.setMinimumSize(new Dimension(300, 10));
    urlTextField.setMinimumSize(new Dimension(300, 10));

    JButton testButton = new JButton("Test");
    testButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            testSettings();
        }
    });

    JPanel panel = new JPanel(new GridBagLayout());
    JLabel nameLabel = new JLabel("Server name:");
    panel.add(nameLabel, new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
    panel.add(nameTextField, new GridBagConstraints(1, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
    JLabel urlLabel = new JLabel("URL:");
    panel.add(urlLabel, new GridBagConstraints(0, 1, 1, 1, 0, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 10), 0, 0));
    panel.add(urlTextField, new GridBagConstraints(1, 1, 1, 1, 1, 0, GridBagConstraints.CENTER,
            GridBagConstraints.HORIZONTAL, new Insets(0, 0, 5, 0), 0, 0));
    panel.add(testButton, new GridBagConstraints(0, 2, 2, 1, 1, 0, GridBagConstraints.WEST,
            GridBagConstraints.NONE, new Insets(0, 0, 5, 0), 0, 0));

    return panel;
}

From source file:net.sf.jabref.gui.preftabs.PreviewPrefsTab.java

public PreviewPrefsTab(JabRefPreferences prefs) {
    this.prefs = prefs;

    GridBagLayout layout = new GridBagLayout();
    firstPanel.setLayout(layout);/*from w  ww .  ja va 2 s .  co m*/
    secondPanel.setLayout(layout);

    setLayout(layout);
    JLabel lab = new JLabel(Localization.lang("Preview") + " 1");
    GridBagConstraints layoutConstraints = new GridBagConstraints();
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.insets = new Insets(2, 2, 2, 2);
    layout.setConstraints(lab, layoutConstraints);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstScrollPane, layoutConstraints);
    firstPanel.add(firstScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.gridwidth = 1;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.anchor = GridBagConstraints.WEST;
    layout.setConstraints(testButton, layoutConstraints);
    firstPanel.add(testButton);
    layout.setConstraints(defaultButton, layoutConstraints);
    firstPanel.add(defaultButton);
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    JPanel newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    firstPanel.add(newPan);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layout.setConstraints(lab, layoutConstraints);
    // p2.add(lab);
    layoutConstraints.weighty = 1;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layout.setConstraints(secondScrollPane, layoutConstraints);
    secondPanel.add(secondScrollPane);
    layoutConstraints.weighty = 0;
    layoutConstraints.weightx = 0;
    layoutConstraints.fill = GridBagConstraints.NONE;
    layoutConstraints.gridwidth = 1;
    layout.setConstraints(testButton2, layoutConstraints);
    secondPanel.add(testButton2);
    layout.setConstraints(defaultButton2, layoutConstraints);
    secondPanel.add(defaultButton2);
    layoutConstraints.gridwidth = 1;
    newPan = new JPanel();
    layoutConstraints.weightx = 1;
    layout.setConstraints(newPan, layoutConstraints);
    secondPanel.add(newPan);

    layoutConstraints.weightx = 1;
    layoutConstraints.weighty = 0;
    layoutConstraints.fill = GridBagConstraints.BOTH;
    layoutConstraints.gridwidth = GridBagConstraints.REMAINDER;
    lab = new JLabel(Localization.lang("Preview") + " 1");
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(firstPanel, layoutConstraints);
    add(firstPanel);
    lab = new JLabel(Localization.lang("Preview") + " 2");
    layoutConstraints.weighty = 0;
    JSeparator sep = new JSeparator(SwingConstants.HORIZONTAL);
    layout.setConstraints(sep, layoutConstraints);
    add(sep);
    layout.setConstraints(lab, layoutConstraints);
    add(lab);
    layoutConstraints.weighty = 1;
    layout.setConstraints(secondPanel, layoutConstraints);
    add(secondPanel);
    layoutConstraints.weighty = 0;

    defaultButton.addActionListener(e -> {
        String tmp = layout1.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_0);
        layout1.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_0).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_0, tmp);
    });

    defaultButton2.addActionListener(e -> {
        String tmp = layout2.getText().replace("\n", "__NEWLINE__");
        PreviewPrefsTab.this.prefs.remove(JabRefPreferences.PREVIEW_1);
        layout2.setText(
                PreviewPrefsTab.this.prefs.get(JabRefPreferences.PREVIEW_1).replace("__NEWLINE__", "\n"));
        PreviewPrefsTab.this.prefs.put(JabRefPreferences.PREVIEW_1, tmp);
    });

    testButton.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout1.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, testPanel, Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });

    testButton2.addActionListener(e -> {
        PreviewPrefsTab.getTestEntry();
        try {
            PreviewPanel testPanel = new PreviewPanel(null, PreviewPrefsTab.entry, null, layout2.getText());
            testPanel.setPreferredSize(new Dimension(800, 350));
            JOptionPane.showMessageDialog(null, new JScrollPane(testPanel), Localization.lang("Preview"),
                    JOptionPane.PLAIN_MESSAGE);
        } catch (StringIndexOutOfBoundsException ex) {
            LOGGER.warn("Parsing error.", ex);
            JOptionPane.showMessageDialog(null,
                    Localization.lang("Parsing error") + ": "
                            + Localization.lang("illegal backslash expression") + ".\n" + ex.getMessage(),
                    Localization.lang("Parsing error"), JOptionPane.ERROR_MESSAGE);
        }
    });
}

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

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel("Pls select a value to choose an enemy or you can create a new "
            + "Enemy entity below. Once selected an Enemy character, its' details will be available below");
    noteLbl.setAlignmentX(0);//from  w w  w.j  av  a2  s.  c om
    //        noteLbl.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (GameCharacter character : GameBean.enemyDetails) {
        System.out.println(character.getName());
        model.addElement(character.getName());
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel enemyDtlLbl = new JLabel("Enemy Character Details : ");
    enemyDtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(enemyDtlLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel imageLbl = new JLabel("Image Path : ");
    panel1.add(imageLbl, c);
    c.gridx = 1;
    JTextField image = new JTextField("");
    image.setColumns(20);
    panel1.add(image, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel healthLbl = new JLabel("Health Pts : ");
    panel1.add(healthLbl, c);
    c.gridx = 1;
    JTextField health = new JTextField("");
    health.setColumns(20);
    panel1.add(health, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    JLabel armoursPtsLbl = new JLabel("Armour Points : ");
    panel1.add(armoursPtsLbl, c);
    c.gridx = 1;
    JTextField armourPts = new JTextField("");
    armourPts.setColumns(20);
    panel1.add(armourPts, c);
    c.gridx = 0;
    c.gridy = 6;
    JLabel attackRngeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRngeLbl, c);
    c.gridx = 1;
    JTextField attackRnge = new JTextField("");
    attackRnge.setColumns(20);
    panel1.add(attackRnge, c);
    c.gridx = 0;
    c.gridy = 7;
    JLabel movementLbl = new JLabel("Movement : ");
    panel1.add(movementLbl, c);
    c.gridx = 1;
    JTextField movement = new JTextField("");
    movement.setColumns(20);
    panel1.add(movement, c);
    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    add(panel1);
    c.gridx = 0;
    c.gridy = 9;
    JLabel validationMess = new JLabel("Pls enter all the fields or pls choose a character from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    add(validationMess, c);
    add(Box.createVerticalGlue());
}

From source file:cool.pandora.modeller.ui.jpanel.base.BagInfoForm.java

@Override
protected JComponent createFormControl() {
    // add field panel
    final JPanel contentPanel = new JPanel(new GridBagLayout());
    int row = 0;//w  w  w .  ja va2  s . c o  m
    final int col = 0;
    GridBagConstraints gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0,
            GridBagConstraints.HORIZONTAL, GridBagConstraints.WEST);
    addFieldPannel = new AddFieldPanel();
    contentPanel.add(addFieldPannel, gbc);

    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 0, 0, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPanel.add(new JSeparator(), gbc);

    // bag-info input form
    form = createFormFields();
    gbc = LayoutUtil.buildGridBagConstraints(col, row++, 1, 1, 1, 1, GridBagConstraints.BOTH,
            GridBagConstraints.WEST);
    contentPanel.add(form, gbc);
    return contentPanel;
}

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

public void doGui() {
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));
    setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JLabel noteLbl = new JLabel(
            "<html><div style='width : 500px;'>Pls select a value to choose an Weapon or you can create a new "
                    + "Weapon entity below. Once selected a weapon, its' details will be available below</div></html>");
    noteLbl.setAlignmentX(0);/*from w w w  .j  av a  2  s.c  o m*/
    add(noteLbl);
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (Item item : GameBean.weaponDetails) {
        if (item instanceof Weapon) {
            model.addElement(((Weapon) item).getName());
        }
    }
    comboBox = new JComboBox(model);
    comboBox.setSelectedIndex(-1);
    comboBox.setMaximumSize(new Dimension(100, 30));
    comboBox.setAlignmentX(0);
    comboBox.setActionCommand("dropDown");
    comboBox.addActionListener(this);
    add(Box.createVerticalStrut(10));
    add(comboBox);
    add(Box.createVerticalStrut(10));
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.WEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 2;
    JLabel weaponDtsLbl = new JLabel("Weapon Details : ");
    weaponDtsLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(weaponDtsLbl, c);
    c.gridwidth = 1;
    c.gridy = 1;
    JLabel nameLbl = new JLabel("Name : ");
    panel1.add(nameLbl, c);
    c.gridx = 1;
    JTextField name = new JTextField("");
    name.setColumns(20);
    panel1.add(name, c);
    c.gridx = 0;
    c.gridy = 2;
    JLabel weaponTypeLbl = new JLabel("Weapon Type : ");
    panel1.add(weaponTypeLbl, c);
    c.gridx = 1;
    JComboBox weaponType = new JComboBox(Configuration.weaponTypes);
    weaponType.setSelectedIndex(0);
    weaponType.setPreferredSize(name.getPreferredSize());
    System.out.println(name.getPreferredSize());
    panel1.add(weaponType, c);
    c.gridx = 0;
    c.gridy = 3;
    JLabel attackRangeLbl = new JLabel("Attack Range : ");
    panel1.add(attackRangeLbl, c);
    c.gridx = 1;
    JTextField attackRange = new JTextField("");
    attackRange.setColumns(20);
    panel1.add(attackRange, c);
    c.gridx = 0;
    c.gridy = 4;
    JLabel attackPtsLbl = new JLabel("Attack Points : ");
    panel1.add(attackPtsLbl, c);
    c.gridx = 1;
    JTextField attackPts = new JTextField("");
    attackPts.setColumns(20);
    panel1.add(attackPts, c);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a weapon from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    //        c.fill = GridBagConstraints.BOTH;
    //        c.gridy = 7;
    //        c.weightx = 1;
    //        c.weighty = 1;
    //        panel1.add(new JLabel(""), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}