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.frostwire.gui.bittorrent.PartialFilesDialog.java

private void setupTable() {
    GridBagConstraints c;//from   w w  w  . j a v  a2 s.c  o  m
    _table = new JTable() {
        private static final long serialVersionUID = -4266029708016964901L;

        public void paint(java.awt.Graphics g) {
            super.paint(g);

            try {
                if (tablePainted) {
                    return;
                }
                tablePainted = true;

                GUIUtils.adjustColumnWidth(_model, 2, 620, 10, this);
                GUIUtils.adjustColumnWidth(_model, 3, 150, 10, this);
            } catch (Exception e) {
                tablePainted = false;
            }

        };
    };

    _table.setPreferredScrollableViewportSize(new Dimension(600, 300));
    _table.setRowSelectionAllowed(false);
    _table.setModel(_model);
    _table.getColumnModel().getColumn(0).setHeaderValue(""); //checkbox
    _table.getColumnModel().getColumn(1).setHeaderValue(""); //icon
    _table.getColumnModel().getColumn(2).setHeaderValue(I18n.tr("File"));
    _table.getColumnModel().getColumn(3).setHeaderValue(I18n.tr("Type"));
    _table.getColumnModel().getColumn(4).setHeaderValue(I18n.tr("Extension"));
    _table.getColumnModel().getColumn(5).setHeaderValue(I18n.tr("Size"));

    _table.getColumnModel().getColumn(0).setPreferredWidth(30);//checkbox
    _table.getColumnModel().getColumn(1).setPreferredWidth(30);//icon
    _table.getColumnModel().getColumn(2).setPreferredWidth(620);
    _table.getColumnModel().getColumn(3).setPreferredWidth(150);
    _table.getColumnModel().getColumn(4).setPreferredWidth(60);
    _table.getColumnModel().getColumn(5).setPreferredWidth(60);

    _scrollPane = new JScrollPane(_table, JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    _table.setFillsViewportHeight(true);
    _table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    c = new GridBagConstraints();
    c.insets = new Insets(5, 5, 5, 5);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.anchor = GridBagConstraints.WEST;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1.0;
    c.weighty = 1.0;
    panel.add(_scrollPane, c);
}

From source file:de.unidue.inf.is.ezdl.gframedl.components.AboutDialog.java

private JPanel getContent() {
    JPanel panel = new JPanel(new GridBagLayout());

    JLabel iconLabel = new JLabel(new ImageIcon(Images.LOGO_EZDL_LARGE_SINGLE.getImage()));

    JTextArea licenseTextArea = new JTextArea(licenseText);
    licenseTextArea.setEditable(false);//from ww  w .j a  v a2s. com
    licenseTextArea.setLineWrap(true);
    licenseTextArea.setWrapStyleWord(true);
    licenseTextArea.setOpaque(false);
    licenseTextArea.setBorder(BorderFactory.createEmptyBorder());
    JScrollPane licenseScrollPane = new JScrollPane(licenseTextArea);

    JTable propertiesTable = new JTable(tableModel);
    propertiesTable.setBackground(Color.WHITE);
    propertiesTable.setShowGrid(false);
    JScrollPane propertiesScrollPane = new JScrollPane(propertiesTable);
    propertiesScrollPane.setBackground(Color.WHITE);
    propertiesScrollPane.getViewport().setBackground(Color.WHITE);

    JButton closeButton = new JButton(I18nSupport.getInstance().getLocString("ezdl.controls.close"));
    closeButton.addActionListener(new ActionListener() {

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

    JTabbedPane tabbedPane = new JTabbedPane();
    tabbedPane.addTab(I18nSupport.getInstance().getLocString("ezdl.licence"), licenseScrollPane);
    tabbedPane.addTab(I18nSupport.getInstance().getLocString("ezdl.properties"), propertiesScrollPane);
    tabbedPane.setBackground(Color.WHITE);

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.insets = new Insets(0, 0, 0, 0);
    c.anchor = GridBagConstraints.CENTER;
    panel.add(iconLabel, c);

    c.gridx = 0;
    c.gridy = 1;
    c.weightx = 1;
    c.weighty = 1;
    c.anchor = GridBagConstraints.CENTER;
    c.fill = GridBagConstraints.BOTH;
    c.insets = new Insets(10, 20, 10, 20);
    panel.add(tabbedPane, c);

    c.gridy = 2;
    c.fill = GridBagConstraints.NONE;
    c.weighty = 0;
    c.insets = new Insets(0, 20, 10, 20);
    panel.add(closeButton, c);

    panel.setBackground(Color.WHITE);

    return panel;
}

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

/**
 * layoutProfileSelectionContent./*from w w  w.j av  a2  s.  co  m*/
 *
 * @param contentPane JPanel
 * @param row         int
 */
private void layoutProfileSelectionContent(final JPanel contentPane, final int row) {
    // content
    // profile selection
    final JLabel bagProfileLabel = new JLabel(bagView.getPropertyMessage("Select Profile:"));
    bagProfileLabel.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    profileList = new JComboBox<>(bagView.getProfileStore().getProfileNames());
    profileList.setName(bagView.getPropertyMessage("bag.label.projectlist"));
    profileList.setSelectedItem(bagView.getPropertyMessage("bag.project.noproject"));
    profileList.setToolTipText(bagView.getPropertyMessage("bag.projectlist.help"));

    GridBagConstraints glbc = new GridBagConstraints();

    final JLabel spacerLabel = new JLabel();
    glbc = LayoutUtil.buildGridBagConstraints(0, row, 1, 1, 5, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.WEST);
    contentPane.add(bagProfileLabel, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(1, row, 1, 1, 40, 50, GridBagConstraints.HORIZONTAL,
            GridBagConstraints.CENTER);
    contentPane.add(profileList, glbc);
    glbc = LayoutUtil.buildGridBagConstraints(2, row, 1, 1, 40, 50, GridBagConstraints.NONE,
            GridBagConstraints.EAST);
    contentPane.add(spacerLabel, glbc);
}

From source file:org.opendatakit.briefcase.ui.settings.SettingsPanelForm.java

/**
 * Method generated by IntelliJ IDEA GUI Designer
 * >>> IMPORTANT!! <<<
 * DO NOT edit this method OR call it in your code!
 *
 * @noinspection ALL/*w  ww.java2s  .  c om*/
 */
private void $$$setupUI$$$() {
    createUIComponents();
    container = new JPanel();
    container.setLayout(new GridBagLayout());
    storageLocationContainer = new JPanel();
    storageLocationContainer.setLayout(new GridBagLayout());
    GridBagConstraints gbc;
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 5;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(storageLocationContainer, gbc);
    storageLocationLabel = new JLabel();
    storageLocationLabel.setText("Storage Location");
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.anchor = GridBagConstraints.WEST;
    storageLocationContainer.add(storageLocationLabel, gbc);
    storageLocationField = new JTextField();
    storageLocationField.setEditable(false);
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.weightx = 1.0;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    storageLocationContainer.add(storageLocationField, gbc);
    storageLocationButtons = new JPanel();
    storageLocationButtons.setLayout(new FlowLayout(FlowLayout.CENTER, 5, 5));
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;
    storageLocationContainer.add(storageLocationButtons, gbc);
    storageLocationClearButton = new JButton();
    storageLocationClearButton.setText("Clear");
    storageLocationClearButton.setVisible(false);
    storageLocationButtons.add(storageLocationClearButton);
    storageLocationChooseButton = new JButton();
    storageLocationChooseButton.setText("Choose...");
    storageLocationButtons.add(storageLocationChooseButton);
    final JPanel spacer1 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    storageLocationContainer.add(spacer1, gbc);
    pullInParallelField = new JCheckBox();
    pullInParallelField.setText("Pull submissions in parallel (experimental)");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 3;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(pullInParallelField, gbc);
    rememberPasswordsField = new JCheckBox();
    rememberPasswordsField.setText("Remember passwords (unencrypted)");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 7;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(rememberPasswordsField, gbc);
    sendUsageDataField = new JCheckBox();
    sendUsageDataField.setText("Send usage data and crash logs to core developers");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 9;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(sendUsageDataField, gbc);
    useHttpProxyField = new JCheckBox();
    useHttpProxyField.setText("Use HTTP Proxy");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 11;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(useHttpProxyField, gbc);
    final JPanel spacer2 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 12;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.insets = new Insets(0, 0, 0, 20);
    container.add(spacer2, gbc);
    httpProxyJostLabel = new JLabel();
    httpProxyJostLabel.setText("Host");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 12;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(httpProxyJostLabel, gbc);
    httpProxyHostField = new JTextField();
    httpProxyHostField.setPreferredSize(new Dimension(150, 30));
    httpProxyHostField.setText("127.0.0.1");
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 12;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(httpProxyHostField, gbc);
    final JPanel spacer3 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 12;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer3, gbc);
    httpProxyPortLabel = new JLabel();
    httpProxyPortLabel.setText("Port");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 13;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(httpProxyPortLabel, gbc);
    final JPanel spacer4 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 5;
    gbc.gridy = 12;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer4, gbc);
    httpProxyPortField.setPreferredSize(new Dimension(150, 30));
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 13;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(httpProxyPortField, gbc);
    final JPanel spacer5 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 10;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer5, gbc);
    final JPanel spacer6 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 6;
    gbc.gridy = 1;
    gbc.gridheight = 13;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer6, gbc);
    final JPanel spacer7 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.gridheight = 13;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    container.add(spacer7, gbc);
    final JPanel spacer8 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 0;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer8, gbc);
    final JPanel spacer9 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 14;
    gbc.gridwidth = 5;
    gbc.weighty = 1.0;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer9, gbc);
    final JPanel spacer10 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer10, gbc);
    final JPanel spacer11 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 4;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer11, gbc);
    final JPanel panel1 = new JPanel();
    panel1.setLayout(new GridBagLayout());
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 15;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.BOTH;
    container.add(panel1, gbc);
    panel1.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Troubleshooting"));
    reloadCacheButton = new JButton();
    reloadCacheButton.setEnabled(false);
    reloadCacheButton.setText("Reload forms from storage location");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 8;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(reloadCacheButton, gbc);
    final JPanel spacer12 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 7;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer12, gbc);
    final JPanel spacer13 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 9;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer13, gbc);
    final JPanel spacer14 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 3;
    gbc.gridy = 8;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer14, gbc);
    final JPanel spacer15 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 8;
    gbc.weightx = 0.5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer15, gbc);
    final JLabel label1 = new JLabel();
    label1.setText("The form list in Briefcase can get out of date if files are moved manually.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label1, gbc);
    final JLabel label2 = new JLabel();
    label2.setText("This reload is always safe.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label2, gbc);
    final JPanel spacer16 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer16, gbc);
    final JPanel spacer17 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer17, gbc);
    final JPanel spacer18 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 4;
    gbc.gridy = 5;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(spacer18, gbc);
    final JPanel spacer19 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 4;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer19, gbc);
    cleanAllPullResumePointsButton = new JButton();
    cleanAllPullResumePointsButton.setEnabled(false);
    cleanAllPullResumePointsButton.setText("Clear pull history");
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 3;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    panel1.add(cleanAllPullResumePointsButton, gbc);
    final JLabel label3 = new JLabel();
    label3.setText("Use if you wish to pull every submission, regardless of last submission pulled.");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.gridwidth = 3;
    gbc.anchor = GridBagConstraints.WEST;
    panel1.add(label3, gbc);
    final JPanel spacer20 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 2;
    gbc.gridy = 2;
    gbc.fill = GridBagConstraints.VERTICAL;
    panel1.add(spacer20, gbc);
    final JPanel spacer21 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 16;
    gbc.gridwidth = 6;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer21, gbc);
    resumeLastPullField = new JCheckBox();
    resumeLastPullField.setText("Start pull from last submission pulled");
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 5;
    gbc.gridwidth = 5;
    gbc.anchor = GridBagConstraints.WEST;
    container.add(resumeLastPullField, gbc);
    final JPanel spacer22 = new JPanel();
    gbc = new GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridy = 6;
    gbc.gridwidth = 5;
    gbc.fill = GridBagConstraints.VERTICAL;
    container.add(spacer22, gbc);
}

From source file:io.github.tavernaextras.biocatalogue.ui.search_results.RESTMethodListCellRenderer.java

/**
 * @return Final state of the {@link GridBagConstraints} instance
 *         that was used to lay out components in the panel.
 *///from ww  w .  j a v  a  2 s . c  om
private GridBagConstraints arrangeLayout() {
    // POPULATE PANEL WITH PREPARED COMPONENTS
    this.setLayout(new GridBagLayout());
    c = new GridBagConstraints();
    c.anchor = GridBagConstraints.NORTHWEST;
    c.fill = GridBagConstraints.HORIZONTAL;

    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 0;
    c.insets = new Insets(8, 6, 6, 3);
    this.add(jlTypeIcon, c);

    c.gridx++;
    c.weightx = 1.0;
    c.insets = new Insets(8, 3, 6, 3);
    this.add(jlItemTitle, c);

    c.gridx++;
    c.gridheight = 8;
    c.weightx = 0;
    c.weighty = 1.0;
    this.add(jlItemStatus, c);

    c.gridx = 1;
    c.gridy++;
    c.gridheight = 1;
    c.weightx = 1.0;
    c.weighty = 0;
    this.add(jlPartOf, c);

    c.fill = GridBagConstraints.NONE;
    c.gridy++;
    this.add(jtDescription, c);

    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridy++;
    this.add(jlMethodType, c);

    c.gridy++;
    this.add(jlUrlTemplate, c);

    c.gridy++;
    this.add(jlMethodParameters, c);

    c.gridy++;
    this.add(jlInputRepresentations, c);

    c.gridy++;
    this.add(jlOutputRepresentations, c);
    return (c);
}

From source file:net.sf.taverna.t2.activities.wsdlsir.views.WSDLActivityConfigurationView.java

private void initComponents() {

    this.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);

    int gridy = 0;

    // title panel
    JPanel titlePanel = new JPanel(new BorderLayout());
    titlePanel.setBackground(Color.WHITE);
    JLabel titleLabel = new JLabel("Security configuration");
    titleLabel.setFont(titleLabel.getFont().deriveFont(Font.BOLD, 13.5f));
    titleLabel.setBorder(new EmptyBorder(10, 10, 0, 10));
    DialogTextArea titleMessage = new DialogTextArea("Select a security profile for the service");
    titleMessage.setMargin(new Insets(5, 20, 10, 10));
    titleMessage.setFont(titleMessage.getFont().deriveFont(11f));
    titleMessage.setEditable(false);//  ww  w.j  av a 2  s .  c  om
    titleMessage.setFocusable(false);
    titlePanel.setBorder(new EmptyBorder(10, 10, 0, 10));
    titlePanel.add(titleLabel, BorderLayout.NORTH);
    titlePanel.add(titleMessage, BorderLayout.CENTER);
    addDivider(titlePanel, SwingConstants.BOTTOM, true);

    // Main panel
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new GridBagLayout());
    mainPanel.setBorder(new EmptyBorder(10, 10, 10, 10));

    //Create the radio buttons
    noSecurityRadioButton = new JRadioButton("None");
    noSecurityRadioButton.addItemListener(this);

    wsSecurityAuthNRadioButton = new JRadioButton("WS-Security username and password authentication");
    wsSecurityAuthNRadioButton.addItemListener(this);

    httpSecurityAuthNRadioButton = new JRadioButton("HTTP username and password authentication");
    httpSecurityAuthNRadioButton.addItemListener(this);

    SAMLSecurityAuthNRadioButton = new JRadioButton("SAML WEB SSO profile authentication");
    SAMLSecurityAuthNRadioButton.addItemListener(this);

    //Group the radio buttons
    buttonGroup = new ButtonGroup();
    buttonGroup.add(noSecurityRadioButton);
    buttonGroup.add(wsSecurityAuthNRadioButton);
    buttonGroup.add(httpSecurityAuthNRadioButton);
    buttonGroup.add(SAMLSecurityAuthNRadioButton);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(noSecurityRadioButton, gbc);

    noSecurityLabel = new JLabel("Service requires no security");
    noSecurityLabel.setFont(noSecurityLabel.getFont().deriveFont(11f));
    //      addDivider(noSecurityLabel, SwingConstants.BOTTOM, false);
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(noSecurityLabel, gbc);

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(httpSecurityAuthNRadioButton, gbc);

    ActionListener usernamePasswordListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {

            // Get Credential Manager UI to get the username and password for the service
            CredentialManagerUI credManagerUI = CredentialManagerUI.getInstance();
            if (credManagerUI != null)
                credManagerUI.newPasswordForService(oldBean.getWsdl());
        }
    };

    httpSecurityAuthNLabel = new JLabel(
            "Service requires HTTP username and password in order to authenticate the user");
    httpSecurityAuthNLabel.setFont(httpSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 10, 10);
    mainPanel.add(httpSecurityAuthNLabel, gbc);

    // Set username and password button;
    setHttpUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setHttpUsernamePasswordButton, gbc);
    setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener);

    /////SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(SAMLSecurityAuthNRadioButton, gbc);

    ActionListener getCookieListener = new ActionListener() {

        /**
         * This listener will use the CallPreparator to obtain the cookies (included shibsession_XXX cookie) and 
         * save it in the Credential Manager (as the password for user "nomatter")
         */
        public void actionPerformed(ActionEvent e) {
            try {
                WSDLParser parser = new WSDLParser(newBean.getWsdl());
                List<String> endpoints = parser.getOperationEndpointLocations(newBean.getOperation());
                for (String endpoint : endpoints) //Actually i am only expecting one endpoint
                {
                    if (debug)
                        System.out
                                .println("Obtaining a SAML cookies to save in credential manager:" + endpoint);

                    Cookie[] cookies = CallPreparator.createCookieForCallToEndpoint(endpoint);

                    // Uncomment for just the shibsession cookie
                    //                  Cookie[] cookiessession = new Cookie[1];
                    //                  for (Cookie cook : cookies)
                    //                     if (cook.getName().contains("shibsession"))
                    //                        cookiessession[0]=cook;
                    //                  cookies=cookiessession;

                    CredentialManager credman = CredentialManager.getInstance();
                    credman.saveUsernameAndPasswordForService(
                            new UsernamePassword("nomatter", serializetoString(cookies)), new URI(endpoint));
                }
            } catch (WSDLException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (ParserConfigurationException ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            } catch (Exception ex) {
                System.err.println(
                        "Problem getting or saving SAML cookie: " + newBean.getWsdl() + ". " + ex.getMessage());
                ex.printStackTrace();
            }
        }
    };

    SAMLSecurityAuthNLabel = new JLabel("<html>"
            + "Service requires SAML Web SSO profile to be perfomed in order to authenticate the user. "
            + "A cookie will be saved in your Credential Manger. "
            + "In the case that it stops working, please delete the entry in your Credential Manager or re-authenticate"
            + "</html>");
    SAMLSecurityAuthNLabel.setFont(SAMLSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(3, 40, 10, 10);
    mainPanel.add(SAMLSecurityAuthNLabel, gbc);

    // Set username and password button;
    setSAMLGETCookieButton = new JButton("Authenticate and save Authentication data in Credential Manger");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setSAMLGETCookieButton, gbc);
    setSAMLGETCookieButton.addActionListener(getCookieListener);

    //END SAML

    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 10, 0, 0);
    mainPanel.add(wsSecurityAuthNRadioButton, gbc);

    wsSecurityAuthNLabel = new JLabel(
            "Service requires WS-Security username and password in order to authenticate the user");
    wsSecurityAuthNLabel.setFont(wsSecurityAuthNLabel.getFont().deriveFont(11f));
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(0, 40, 0, 0);
    mainPanel.add(wsSecurityAuthNLabel, gbc);

    // Password type list
    passwordTypeComboBox = new JComboBox(passwordTypes);
    passwordTypeComboBox.setRenderer(new ComboBoxTooltipRenderer());
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(10, 40, 0, 0);
    mainPanel.add(passwordTypeComboBox, gbc);

    // 'Add timestamp' checkbox
    addTimestampCheckBox = new JCheckBox("Add a timestamp to SOAP message");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.WEST;
    gbc.insets = new Insets(5, 40, 10, 10);
    mainPanel.add(addTimestampCheckBox, gbc);

    // Set username and password button;
    setWsdlUsernamePasswordButton = new JButton("Set username and password");
    gbc.gridx = 0;
    gbc.gridy = gridy++;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.EAST;
    gbc.insets = new Insets(0, 40, 10, 10);
    gbc.weightx = 1.0;
    gbc.weighty = 1.0; // add any vertical space to this component
    mainPanel.add(setWsdlUsernamePasswordButton, gbc);
    setWsdlUsernamePasswordButton.addActionListener(usernamePasswordListener);

    addDivider(mainPanel, SwingConstants.BOTTOM, true);

    // OK/Cancel button panel
    JPanel okCancelPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT));
    JButton okButton = new JButton("OK");
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okPressed();
        }
    });
    JButton cancelButton = new JButton("Cancel");
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            cancelPressed();
        }
    });
    okCancelPanel.add(cancelButton);
    okCancelPanel.add(okButton);

    // Enable/disable controls based on what is the current security profiles
    String securityProfile = oldBean.getSecurityProfile();
    if (securityProfile == null) {
        noSecurityRadioButton.setSelected(true);
    } else {
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            wsSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.HTTP_BASIC_AUTHN)
                || securityProfile.equals(SecurityProfiles.HTTP_DIGEST_AUTHN)) {
            httpSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.SAMLWEBSSOAUTH)) {
            SAMLSecurityAuthNRadioButton.setSelected(true);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_PLAINTEXTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(PLAINTEXT_PASSWORD);
        } else if (securityProfile.equals(SecurityProfiles.WSSECURITY_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)) {
            passwordTypeComboBox.setSelectedItem(DIGEST_PASSWORD);
        }
        if (securityProfile.equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_DIGESTPASSWORD)
                || securityProfile
                        .equals(SecurityProfiles.WSSECURITY_TIMESTAMP_USERNAMETOKEN_PLAINTEXTPASSWORD)) {
            addTimestampCheckBox.setSelected(true);
        } else {
            addTimestampCheckBox.setSelected(false);
        }
    }

    // Put everything together
    JPanel layoutPanel = new JPanel(new BorderLayout());
    layoutPanel.add(titlePanel, BorderLayout.NORTH);
    layoutPanel.add(mainPanel, BorderLayout.CENTER);
    layoutPanel.add(okCancelPanel, BorderLayout.SOUTH);
    layoutPanel.setPreferredSize(new Dimension(550, 490));

    this.getContentPane().add(layoutPanel);
    this.pack();
}

From source file:de.codesourcery.gittimelapse.MyFrame.java

public MyFrame(File file, GitHelper gitHelper) throws RevisionSyntaxException, MissingObjectException,
        IncorrectObjectTypeException, AmbiguousObjectException, IOException, GitAPIException {
    super("GIT timelapse: " + file.getAbsolutePath());
    if (gitHelper == null) {
        throw new IllegalArgumentException("gitHelper must not be NULL");
    }/* w w  w.  j a v a 2  s.  c  o m*/

    this.gitHelper = gitHelper;
    this.file = file;
    this.diffPanel = new DiffPanel();

    final JDialog dialog = new JDialog((Frame) null, "Please wait...", false);
    dialog.getContentPane().setLayout(new BorderLayout());
    dialog.getContentPane().add(new JLabel("Please wait, locating revisions..."), BorderLayout.CENTER);
    dialog.pack();
    dialog.setVisible(true);

    final IProgressCallback callback = new IProgressCallback() {

        @Override
        public void foundCommit(ObjectId commitId) {
            System.out.println("*** Found commit " + commitId);
        }
    };

    System.out.println("Locating commits...");
    commitList = gitHelper.findCommits(file, callback);

    dialog.setVisible(false);

    if (commitList.isEmpty()) {
        throw new RuntimeException("Found no commits");
    }
    setMenuBar(createMenuBar());

    diffModeChooser.setModel(new DefaultComboBoxModel<MyFrame.DiffDisplayMode>(DiffDisplayMode.values()));
    diffModeChooser.setSelectedItem(DiffDisplayMode.ALIGN_CHANGES);
    diffModeChooser.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
            try {
                diffPanel.showRevision(commit);
            } catch (IOException | PatchApplyException e1) {
                e1.printStackTrace();
            }
        }
    });

    diffModeChooser.setRenderer(new DefaultListCellRenderer() {

        @Override
        public Component getListCellRendererComponent(JList<?> list, Object value, int index,
                boolean isSelected, boolean cellHasFocus) {
            Component result = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
            DiffDisplayMode mode = (DiffDisplayMode) value;
            switch (mode) {
            case ALIGN_CHANGES:
                setText("Align changes");
                break;
            case REGULAR:
                setText("Regular");
                break;
            default:
                setText(mode.toString());
            }
            return result;
        }
    });

    revisionSlider = new JSlider(1, commitList.size());

    revisionSlider.setPaintLabels(true);
    revisionSlider.setPaintTicks(true);

    addKeyListener(keyListener);
    getContentPane().addKeyListener(keyListener);

    if (commitList.size() < 10) {
        revisionSlider.setMajorTickSpacing(1);
        revisionSlider.setMinorTickSpacing(1);
    } else {
        revisionSlider.setMajorTickSpacing(5);
        revisionSlider.setMinorTickSpacing(1);
    }

    final ObjectId latestCommit = commitList.getLatestCommit();
    if (latestCommit != null) {
        revisionSlider.setValue(1 + commitList.indexOf(latestCommit));
        revisionSlider.setToolTipText(latestCommit.getName());
    }

    revisionSlider.addChangeListener(new ChangeListener() {

        @Override
        public void stateChanged(ChangeEvent e) {
            if (!revisionSlider.getValueIsAdjusting()) {
                final ObjectId commit = commitList.getCommit(revisionSlider.getValue() - 1);
                long time = -System.currentTimeMillis();
                try {
                    diffPanel.showRevision(commit);
                } catch (IOException | PatchApplyException e1) {
                    e1.printStackTrace();
                } finally {
                    time += System.currentTimeMillis();
                }
                if (Main.DEBUG_MODE) {
                    System.out.println("Rendering time: " + time);
                }
            }
        }
    });

    getContentPane().setLayout(new GridBagLayout());

    GridBagConstraints cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(new JLabel("Diff display mode:"), cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 1;
    cnstrs.gridy = 0;
    cnstrs.gridwidth = 1;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 0;
    cnstrs.weighty = 0;
    cnstrs.fill = GridBagConstraints.NONE;

    getContentPane().add(diffModeChooser, cnstrs);

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

    getContentPane().add(revisionSlider, cnstrs);

    cnstrs = new GridBagConstraints();
    cnstrs.gridx = 0;
    cnstrs.gridy = 1;
    cnstrs.gridwidth = 3;
    cnstrs.gridheight = 1;
    cnstrs.weightx = 1;
    cnstrs.weighty = 1;
    cnstrs.fill = GridBagConstraints.BOTH;

    getContentPane().add(diffPanel, cnstrs);

    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

    if (latestCommit != null) {
        diffPanel.showRevision(latestCommit);
    }
}

From source file:biomine.bmvis2.crawling.CrawlSuggestionList.java

public CrawlSuggestionList() {
    // setMinimumSize(new Dimension(600,200));

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

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

    c.weightx = 1;/* w w w  .j a  va2s  . c o  m*/
    c.weighty = 0;
    c.gridx = 0;
    c.gridy = 0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.gridwidth = 1;
    c.gridheight = 1;

    dbSelect = new JComboBox();
    for (String db : Databases.getDatabases()) {
        dbSelect.addItem(db);
    }

    dbSelect.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            suggestionQuery.setDb(dbSelect.getSelectedItem().toString());
        }
    });

    this.add(dbSelect, c);
    c.gridy++;
    this.add(query, c);

    c.gridwidth = 1;
    c.weighty = 3;
    c.weightx = 10;
    c.fill = GridBagConstraints.BOTH;
    c.gridx = 0;
    c.gridy++;
    // listScroller.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    listScroller = new JScrollPane(list);
    this.add(listScroller, c);

    c.weighty = 0;
    c.weightx = 10;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy++;
    this.add(new JLabel("Selected nodes:"), c);

    c.weighty = 3;
    c.weightx = 10;
    c.gridwidth = 1;
    c.gridx = 0;
    c.gridy++;
    JScrollPane selectedScroller = new JScrollPane(selectedList);
    this.add(selectedScroller, c);

    // initialize components
    back.setAction(new AbstractAction("< back to unfiltered results") {

        public void actionPerformed(ActionEvent arg0) {
            suggestionQuery.back();
            updateList();
        }
    });
    query.addCaretListener(new CaretListener() {
        public void caretUpdate(CaretEvent arg0) {
            updateList();
        }

    });

    list.setModel(new SuggestListModel());
    list.addMouseListener(new SuggestMouseListener(list));
    list.addMouseMotionListener(new SuggestMouseListener(list));

    list.setCellRenderer(new SuggestCellRenderer());

    selectedList.setModel(new SelectedListModel());
    selectedList.addMouseListener(new SuggestMouseListener(selectedList));
    selectedList.addMouseMotionListener(new SuggestMouseListener(selectedList));
    selectedList.setCellRenderer(new SuggestCellRenderer());
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Creates the center panel.// w ww  . j  ava  2s  .  co m
 *
 * @return the created center panel
 */
private Container createCenter() {
    JPanel centerPanel = new JPanel(new GridBagLayout());

    centerPanel.setBackground(Color.WHITE);
    centerPanel.setBorder(BorderFactory.createEmptyBorder(3, 0, 3, 3));

    GridBagConstraints constraints = new GridBagConstraints();

    initSmsLabel(centerPanel);
    initTextArea(centerPanel);

    smsCharCountLabel = new JLabel(String.valueOf(smsCharCount));
    smsCharCountLabel.setForeground(Color.GRAY);
    smsCharCountLabel.setVisible(false);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 3;
    constraints.gridy = 0;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    constraints.insets = new Insets(0, 2, 0, 2);
    constraints.gridheight = 1;
    constraints.gridwidth = 1;
    centerPanel.add(smsCharCountLabel, constraints);

    smsNumberLabel = new JLabel(String.valueOf(smsNumberCount)) {
        @Override
        public void paintComponent(Graphics g) {
            AntialiasingManager.activateAntialiasing(g);
            g.setColor(getBackground());
            g.fillOval(0, 0, getWidth(), getHeight());

            super.paintComponent(g);
        }
    };
    smsNumberLabel.setHorizontalAlignment(JLabel.CENTER);
    smsNumberLabel.setPreferredSize(new Dimension(18, 18));
    smsNumberLabel.setMinimumSize(new Dimension(18, 18));
    smsNumberLabel.setForeground(Color.WHITE);
    smsNumberLabel.setBackground(Color.GRAY);
    smsNumberLabel.setVisible(false);

    constraints.anchor = GridBagConstraints.NORTHEAST;
    constraints.fill = GridBagConstraints.NONE;
    constraints.gridx = 4;
    constraints.gridy = 0;
    constraints.weightx = 0f;
    constraints.weighty = 0f;
    constraints.insets = new Insets(0, 2, 0, 2);
    constraints.gridheight = 1;
    constraints.gridwidth = 1;
    centerPanel.add(smsNumberLabel, constraints);

    return centerPanel;
}

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

private JPanel getJPanelOption() {
    if (jPanelOption == null) {
        jPanelOption = new JPanel();
        jPanelOption.setLayout(new GridBagLayout());

        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
        gridBagConstraints.gridx = 0;//from   www  . j  a v  a  2s . c  o  m
        gridBagConstraints.gridy = 0;
        gridBagConstraints.insets = new Insets(0, 5, 0, 5);
        jPanelOption.add(getJCheckSamePath(), gridBagConstraints);

    }
    return jPanelOption;
}