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.digitalgeneralists.assurance.ui.components.SettingsPanel.java

@Override
protected void initializeComponent() {
    if (!this.initialized) {
        this.dialogTitle = Application.applicationShortName + " Settings";

        // NOTE:  There is no notion of add-mode in this dialog.  There should
        // always be a single instance of the application configuration.
        if (this.configuration == null) {
            this.configuration = ApplicationConfiguration.createDefaultConfiguration();
        }//from w w  w .  j  a  v  a2 s .  c  om
        this.mode = AssuranceDialogMode.EDIT;

        GridBagLayout gridbag = new GridBagLayout();
        this.setLayout(gridbag);

        final JPanel scanSettingsPanel = new JPanel();
        scanSettingsPanel.setLayout(new GridBagLayout());

        Border scanSettingsPanelBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
        scanSettingsPanelBorder = BorderFactory.createTitledBorder(scanSettingsPanelBorder, "Scan Settings",
                TitledBorder.CENTER, TitledBorder.TOP);

        GridBagConstraints scanSettingsPanelConstraints = new GridBagConstraints();
        scanSettingsPanelConstraints.anchor = GridBagConstraints.NORTH;
        scanSettingsPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
        scanSettingsPanelConstraints.gridx = 0;
        scanSettingsPanelConstraints.gridy = 0;
        scanSettingsPanelConstraints.weightx = 1.0;
        scanSettingsPanelConstraints.weighty = 1.0;
        scanSettingsPanelConstraints.gridheight = 1;
        scanSettingsPanelConstraints.gridwidth = 2;
        scanSettingsPanelConstraints.insets = new Insets(5, 5, 5, 5);

        scanSettingsPanel.setBorder(scanSettingsPanelBorder);
        this.add(scanSettingsPanel, scanSettingsPanelConstraints);

        GridBagConstraints ignoredFileNamesLabelConstraints = new GridBagConstraints();
        ignoredFileNamesLabelConstraints.anchor = GridBagConstraints.NORTHWEST;
        ignoredFileNamesLabelConstraints.fill = GridBagConstraints.NONE;
        ignoredFileNamesLabelConstraints.gridx = 0;
        ignoredFileNamesLabelConstraints.gridy = 0;
        ignoredFileNamesLabelConstraints.weightx = 1.0;
        ignoredFileNamesLabelConstraints.weighty = 1.0;
        ignoredFileNamesLabelConstraints.gridheight = 1;
        ignoredFileNamesLabelConstraints.gridwidth = 1;
        ignoredFileNamesLabelConstraints.insets = new Insets(5, 10, 0, 5);

        final JLabel ignoredFileNamesLabel = new JLabel("Ignored Files", SwingConstants.LEFT);
        scanSettingsPanel.add(ignoredFileNamesLabel, ignoredFileNamesLabelConstraints);

        GridBagConstraints ignoredFileNamesTextFieldConstraints = new GridBagConstraints();
        ignoredFileNamesTextFieldConstraints.anchor = GridBagConstraints.NORTH;
        ignoredFileNamesTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        ignoredFileNamesTextFieldConstraints.gridx = 0;
        ignoredFileNamesTextFieldConstraints.gridy = 1;
        ignoredFileNamesTextFieldConstraints.weightx = 1.0;
        ignoredFileNamesTextFieldConstraints.weighty = 1.0;
        ignoredFileNamesTextFieldConstraints.gridheight = 1;
        ignoredFileNamesTextFieldConstraints.gridwidth = 2;
        ignoredFileNamesTextFieldConstraints.insets = new Insets(2, 5, 5, 5);

        GridBagConstraints ignoredFileExtensionsLabelConstraints = new GridBagConstraints();
        ignoredFileExtensionsLabelConstraints.anchor = GridBagConstraints.NORTHWEST;
        ignoredFileExtensionsLabelConstraints.fill = GridBagConstraints.NONE;
        ignoredFileExtensionsLabelConstraints.gridx = 0;
        ignoredFileExtensionsLabelConstraints.gridy = 2;
        ignoredFileExtensionsLabelConstraints.weightx = 1.0;
        ignoredFileExtensionsLabelConstraints.weighty = 1.0;
        ignoredFileExtensionsLabelConstraints.gridheight = 1;
        ignoredFileExtensionsLabelConstraints.gridwidth = 1;
        ignoredFileExtensionsLabelConstraints.insets = new Insets(5, 10, 0, 5);

        final JLabel ignoredFileExtensionsLabel = new JLabel("Ignored File Extensions", SwingConstants.LEFT);
        scanSettingsPanel.add(ignoredFileExtensionsLabel, ignoredFileExtensionsLabelConstraints);

        GridBagConstraints ignoredFileExtensionsTextFieldConstraints = new GridBagConstraints();
        ignoredFileExtensionsTextFieldConstraints.anchor = GridBagConstraints.NORTH;
        ignoredFileExtensionsTextFieldConstraints.fill = GridBagConstraints.HORIZONTAL;
        ignoredFileExtensionsTextFieldConstraints.gridx = 0;
        ignoredFileExtensionsTextFieldConstraints.gridy = 3;
        ignoredFileExtensionsTextFieldConstraints.weightx = 1.0;
        ignoredFileExtensionsTextFieldConstraints.weighty = 1.0;
        ignoredFileExtensionsTextFieldConstraints.gridheight = 1;
        ignoredFileExtensionsTextFieldConstraints.gridwidth = 2;
        ignoredFileExtensionsTextFieldConstraints.insets = new Insets(2, 5, 5, 5);

        scanSettingsPanel.add(this.ignoredFileNamesTextField, ignoredFileNamesTextFieldConstraints);
        this.ignoredFileNamesTextField.getDocument().addDocumentListener(this.textPropertyValidationListener);
        scanSettingsPanel.add(this.ignoredFileExtensionsTextField, ignoredFileExtensionsTextFieldConstraints);
        this.ignoredFileExtensionsTextField.getDocument()
                .addDocumentListener(this.textPropertyValidationListener);

        GridBagConstraints numberScanThreadsLabelConstraints = new GridBagConstraints();
        numberScanThreadsLabelConstraints.anchor = GridBagConstraints.NORTH;
        numberScanThreadsLabelConstraints.fill = GridBagConstraints.NONE;
        numberScanThreadsLabelConstraints.gridx = 0;
        numberScanThreadsLabelConstraints.gridy = 4;
        numberScanThreadsLabelConstraints.weightx = 1.0;
        numberScanThreadsLabelConstraints.weighty = 1.0;
        numberScanThreadsLabelConstraints.gridheight = 1;
        numberScanThreadsLabelConstraints.gridwidth = 1;
        numberScanThreadsLabelConstraints.insets = new Insets(10, 5, 0, 5);

        final JLabel numberOfThreadsLabel = new JLabel("Number of Threads", SwingConstants.RIGHT);
        scanSettingsPanel.add(numberOfThreadsLabel, numberScanThreadsLabelConstraints);

        GridBagConstraints numberScanThreadsSpinnerConstraints = new GridBagConstraints();
        numberScanThreadsSpinnerConstraints.anchor = GridBagConstraints.NORTHWEST;
        numberScanThreadsSpinnerConstraints.fill = GridBagConstraints.NONE;
        numberScanThreadsSpinnerConstraints.gridx = 1;
        numberScanThreadsSpinnerConstraints.gridy = 4;
        numberScanThreadsSpinnerConstraints.weightx = 1.0;
        numberScanThreadsSpinnerConstraints.weighty = 1.0;
        numberScanThreadsSpinnerConstraints.gridheight = 1;
        numberScanThreadsSpinnerConstraints.gridwidth = 1;
        numberScanThreadsSpinnerConstraints.insets = new Insets(5, 5, 5, 5);

        scanSettingsPanel.add(this.numberScanThreadsSpinner, numberScanThreadsSpinnerConstraints);

        if (this.configuration != null) {
            this.ignoredFileNamesTextField.setText(this.configuration.getIgnoredFileNames());
            this.ignoredFileExtensionsTextField.setText(this.configuration.getIgnoredFileExtensions());
            this.numberScanThreadsSpinner.setValue(this.configuration.getNumberOfScanThreads());
        }

        this.initialized = true;
    }
}

From source file:logdruid.ui.mainpanel.EventRecordingSelectorPanel.java

/**
 * Create the panel.// w w  w  .j a  va 2s.c  om
 */
public EventRecordingSelectorPanel(final Repository rep, Source src) {
    repository = rep;
    source = src;
    records = rep.getRecordings(EventRecording.class);
    // Collections.sort(records);
    Iterator it = records.iterator();
    while (it.hasNext()) {
        Recording record = (Recording) it.next();
        data.add(new Object[] { record.getName(), record.getRegexp(), record.getType(),
                src.isActiveRecordingOnSource(record) });
    }

    model = new logdruid.ui.mainpanel.EventRecordingSelectorPanel.MyTableModel(data, header);
    logger.info("source is " + ((source == null) ? "null" : src.getSourceName()));
    JPanel panel_1 = new JPanel();
    GridBagConstraints gbc_panel_1 = new GridBagConstraints();
    gbc_panel_1.fill = GridBagConstraints.BOTH;
    gbc_panel_1.insets = new Insets(5, 0, 5, 5);
    gbc_panel_1.gridx = 1;
    gbc_panel_1.gridy = 0;
    panel_1.setLayout(new BorderLayout(0, 0));

    table = new JTable(model);
    JScrollPane scrollPane = new JScrollPane(table);
    panel_1.add(scrollPane, BorderLayout.CENTER);

    table.setPreferredScrollableViewportSize(new Dimension(0, 150));
    table.setFillsViewportHeight(true);
    table.setAutoCreateRowSorter(true);

    // Set up column sizes.
    initColumnSizes(table);

    setLayout(new BorderLayout(0, 0));

    JSplitPane splitPane = new JSplitPane();
    splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT);
    add(splitPane);
    jPanelDetail = new JPanel();
    splitPane.setBottomComponent(jPanelDetail);
    splitPane.setTopComponent(panel_1);

    GridBagConstraints gbc_jPanelDetail = new GridBagConstraints();
    gbc_jPanelDetail.insets = new Insets(0, 0, 0, 5);
    gbc_jPanelDetail.fill = GridBagConstraints.BOTH;
    gbc_jPanelDetail.gridx = 1;
    gbc_jPanelDetail.gridy = 3;
    jPanelDetail.setLayout(new BorderLayout(0, 0));
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {

        public void valueChanged(ListSelectionEvent e) {
            int selectedRow = ((table.getSelectedRow() != -1)
                    ? table.convertRowIndexToModel(table.getSelectedRow())
                    : -1);
            logger.info("ListSelectionListener - selectedRow: " + selectedRow);
            if (selectedRow >= 0) {
                if (jPanelDetail != null) {
                    logger.debug("ListSelectionListener - valueChanged");
                    jPanelDetail.removeAll();
                    recEditor = getEditor(repository.getRecording(EventRecording.class, selectedRow));
                    if (recEditor != null) {
                        jPanelDetail.add(recEditor, BorderLayout.CENTER);
                    }
                    jPanelDetail.revalidate();
                }
            }
        }
    });
    if (repository.getRecordings(EventRecording.class).size() > 0) {
        recEditor = getEditor(repository.getRecording(EventRecording.class, 0));
        jPanelDetail.add(recEditor, BorderLayout.CENTER);
        table.setRowSelectionInterval(0, 0);
    }
    if (model.getRowCount() > 0) {
        table.getRowSorter().toggleSortOrder(0);
        table.setRowSelectionInterval(0, 0);
    }
}

From source file:com.sec.ose.osi.ui.frm.main.manage.dialog.JDlgProjectCreate.java

/**
 * This method initializes this/*  w w w.j  av a  2 s.c  o  m*/
 * 
 * @return void
 */
private void initialize() {
    GridBagConstraints gridBagConstraints5 = new GridBagConstraints();
    gridBagConstraints5.gridx = 0;
    gridBagConstraints5.weightx = 0.1;
    gridBagConstraints5.weighty = 0.0;
    gridBagConstraints5.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints5.insets = new Insets(0, 10, 0, 0);
    gridBagConstraints5.gridy = 1;
    GridBagConstraints gridBagConstraints41 = new GridBagConstraints();
    gridBagConstraints41.gridx = 0;
    gridBagConstraints41.weightx = 0.1;
    gridBagConstraints41.anchor = GridBagConstraints.CENTER;
    gridBagConstraints41.insets = new Insets(0, 10, 20, 0);
    gridBagConstraints41.fill = GridBagConstraints.HORIZONTAL;
    gridBagConstraints41.gridy = 0;
    GridBagConstraints gridBagConstraints3 = new GridBagConstraints();
    gridBagConstraints3.gridx = 1;
    gridBagConstraints3.gridheight = 2;
    gridBagConstraints3.anchor = GridBagConstraints.NORTH;
    gridBagConstraints3.insets = new Insets(10, 0, 0, 0);
    gridBagConstraints3.gridy = 0;
    this.setSize(600, 250);
    this.setLayout(new GridBagLayout());
    this.add(getJPanelButton(), gridBagConstraints3);
    this.add(getJPanelPjtName(), gridBagConstraints41);
    this.add(getJPanelSourceLocation(), gridBagConstraints5);

    getJTextFieldSourceLocation().setText(strPath);
    getJTextFieldSourceLocation().setToolTipText(strPath);
}

From source file:com.univocity.app.swing.DataAnalysisWindow.java

protected JPanel getStatusPanel() {
    if (statusPanel == null) {
        statusPanel = new JPanel();
        statusPanel.setLayout(new GridBagLayout());

        GridBagConstraints c = new GridBagConstraints();
        c.gridx = 0;/*from   w w w .j  a  v  a 2 s.  c  om*/
        c.gridy = 0;
        c.insets = new Insets(0, 5, 0, 5);
        statusPanel.add(getSearchLabel(), c);

        c.gridx++;
        c.ipadx = 350;
        statusPanel.add(getSearchField(), c);

        c.gridx++;
        c.ipadx = 0;
        statusPanel.add(getBtSearchNext(), c);

        c.gridx++;
        c.insets = new Insets(0, 5, 0, 20);
        statusPanel.add(getBtSearchPrevious(), c);

        c.gridx++;
        c.insets = new Insets(0, 5, 0, 5);
        statusPanel.add(getStatusLabel(), c);

        c.gridx++;
        statusPanel.add(getStatusInformation(), c);

        c.gridx++;
        c.weightx = 1.0;
        statusPanel.add(new JPanel(), c);

    }
    return statusPanel;
}

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

/**
 * Creates a new SshToolsConnectionHostTab object.
 *//*from  w w w . ja va 2 s  .c o m*/
public SshToolsConnectionHostTab() {
    super();

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

public void doCommonStuffForContent() {
    JPanel panel1 = new JPanel();
    panel1.setAlignmentX(0);/*from   w  ww  .ja v  a 2s . c  o m*/
    panel1.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTHWEST;
    c.insets = new Insets(5, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0.2;
    c.gridwidth = 2;
    JLabel dtlLbl = new JLabel(type + "Details : ");
    dtlLbl.setFont(new Font("Times New Roman", Font.BOLD, 15));
    panel1.add(dtlLbl, 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);
    if (ringPanel) {
        createComponentsForRing(panel1, c);
    } else if (armourPanel) {
        createComponentsForArmour(panel1, c);
    } else if (potionPanel) {
        createComponentsForPotion(panel1, c);
    } else if (treasurePanel) {
        createComponentsForTreasure(panel1, c);
    }
    c.gridx = 0;
    c.gridy = c.gridy + 1;
    c.gridwidth = 2;
    JButton submit = new JButton("Save");
    submit.addActionListener(this);
    submit.setActionCommand("button");
    panel1.add(submit, c);
    c.gridx = 0;
    c.gridy = c.gridy + 1;
    c.gridwidth = 2;
    c.weighty = 0;
    c.weightx = 1;
    validationMess = new JLabel("Pls enter all the fields or pls choose a " + type + " from the drop down");
    validationMess.setForeground(Color.red);
    validationMess.setVisible(false);
    panel1.add(validationMess, c);
    c.gridy++;
    c.weighty = 1;
    c.weightx = 1;
    panel1.add(new JPanel(), c);
    panel1.setBorder(LineBorder.createGrayLineBorder());
    add(panel1);
    add(Box.createVerticalGlue());
}

From source file:com._17od.upm.gui.OptionsDialog.java

public OptionsDialog(JFrame frame) {
    super(frame, Translator.translate("options"), true);

    Container container = getContentPane();

    // Create a pane with an empty border for spacing
    Border emptyBorder = BorderFactory.createEmptyBorder(2, 5, 5, 5);
    JPanel emptyBorderPanel = new JPanel();
    emptyBorderPanel.setLayout(new BoxLayout(emptyBorderPanel, BoxLayout.Y_AXIS));
    emptyBorderPanel.setBorder(emptyBorder);
    container.add(emptyBorderPanel);//from  w ww.j  av  a2  s .  c o  m

    // ******************
    // *** The DB TO Load On Startup Section
    // ******************
    // Create a pane with an title etched border
    Border etchedBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
    Border etchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("general") + ' ');
    JPanel mainPanel = new JPanel(new GridBagLayout());
    mainPanel.setBorder(etchedTitleBorder);
    emptyBorderPanel.add(mainPanel);

    GridBagConstraints c = new GridBagConstraints();

    // The "Database to Load on Startup" row
    JLabel urlLabel = new JLabel(Translator.translate("dbToLoadOnStartup"));
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(urlLabel, c);

    // The "Database to Load on Startup" input field row
    dbToLoadOnStartup = new JTextField(Preferences.get(Preferences.ApplicationOptions.DB_TO_LOAD_ON_STARTUP),
            25);
    dbToLoadOnStartup.setHorizontalAlignment(JTextField.LEFT);
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(dbToLoadOnStartup, c);

    JButton dbToLoadOnStartupButton = new JButton("...");
    dbToLoadOnStartupButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            getDBToLoadOnStartup();
        }
    });
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(0, 0, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(dbToLoadOnStartupButton, c);

    // The "Language" label row
    JLabel localeLabel = new JLabel(Translator.translate("language"));
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(localeLabel, c);

    // The "Locale" field row
    localeComboBox = new JComboBox(getSupportedLocaleNames());
    for (int i = 0; i < localeComboBox.getItemCount(); i++) {
        // If the locale language is blank then set it to the English language
        // I'm not sure why this happens. Maybe it's because the default locale
        // is English???
        String currentLanguage = Translator.getCurrentLocale().getLanguage();
        if (currentLanguage.equals("")) {
            currentLanguage = "en";
        }

        if (currentLanguage.equals(Translator.SUPPORTED_LOCALES[i].getLanguage())) {
            localeComboBox.setSelectedIndex(i);
            break;
        }
    }
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 8, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(localeComboBox, c);

    // The "Hide account password" row
    Boolean hideAccountPassword = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true"));
    hideAccountPasswordCheckbox = new JCheckBox(Translator.translate("hideAccountPassword"),
            hideAccountPassword.booleanValue());
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(hideAccountPasswordCheckbox, c);

    // The "Database auto lock" row
    Boolean databaseAutoLock = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK, "false"));
    databaseAutoLockCheckbox = new JCheckBox(Translator.translate("databaseAutoLock"),
            databaseAutoLock.booleanValue());
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(databaseAutoLockCheckbox, c);
    databaseAutoLockCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            databaseAutoLockTime.setEnabled(e.getStateChange() == ItemEvent.SELECTED);
        }
    });

    // The "Database auto lock" field row
    databaseAutoLockTime = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.DATABASE_AUTO_LOCK_TIME), 5);
    c.gridx = 1;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(databaseAutoLockTime, c);
    databaseAutoLockTime.setEnabled(databaseAutoLockCheckbox.isSelected());

    // The "Generated password length" row
    accountPasswordLengthLabel = new JLabel(Translator.translate("generatedPasswodLength"));
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    mainPanel.add(accountPasswordLengthLabel, c);

    accountPasswordLength = new JTextField(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, "8"), 5);
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    mainPanel.add(accountPasswordLength, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // ******************
    // *** The HTTPS Section
    // ******************
    // Create a pane with an title etched border
    Border httpsEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder, " HTTPS ");
    final JPanel httpsPanel = new JPanel(new GridBagLayout());
    httpsPanel.setBorder(httpsEtchedTitleBorder);
    emptyBorderPanel.add(httpsPanel);

    // The "Accept Self Sigend Certificates" checkbox row
    Boolean acceptSelfSignedCerts = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.HTTPS_ACCEPT_SELFSIGNED_CERTS, "false"));
    acceptSelfSignedCertsCheckbox = new JCheckBox(Translator.translate("acceptSelfSignedCerts"),
            acceptSelfSignedCerts.booleanValue());
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    httpsPanel.add(acceptSelfSignedCertsCheckbox, c);

    // ******************
    // *** The Proxy Section
    // ******************
    // Create a pane with an title etched border
    Border proxyEtchedTitleBorder = BorderFactory.createTitledBorder(etchedBorder,
            ' ' + Translator.translate("httpProxy") + ' ');
    final JPanel proxyPanel = new JPanel(new GridBagLayout());
    proxyPanel.setBorder(proxyEtchedTitleBorder);
    emptyBorderPanel.add(proxyPanel);

    // The "Enable Proxy" row
    Boolean proxyEnabled = new Boolean(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_ENABLED));
    enableProxyCheckbox = new JCheckBox(Translator.translate("enableProxy"), proxyEnabled.booleanValue());
    enableProxyCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                enableProxyComponents(true);
            } else {
                enableProxyComponents(false);
            }
        }
    });
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 2, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(enableProxyCheckbox, c);

    // The "HTTP Proxy" label row
    proxyLabel = new JLabel(Translator.translate("httpProxy"));
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyLabel, c);

    // The "HTTP Proxy Port" label
    proxyPortLabel = new JLabel(Translator.translate("port"));
    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPortLabel, c);

    // The "HTTP Proxy" field row
    httpProxyHost = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_HOST), 20);
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyHost, c);

    httpProxyPort = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PORT), 6);
    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPort, c);

    // The "HTTP Proxy Username" label row
    proxyUsernameLabel = new JLabel(Translator.translate("httpProxyUsername"));
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyUsernameLabel, c);

    // The "HTTP Proxy Username" field row
    httpProxyUsername = new JTextField(Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_USERNAME), 20);
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyUsername, c);

    // The "HTTP Proxy Password" label row
    proxyPasswordLabel = new JLabel(Translator.translate("httpProxyPassword"));
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 3, 0);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 2;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(proxyPasswordLabel, c);

    // The "HTTP Proxy Password" field row
    String encodedPassword = Preferences.get(Preferences.ApplicationOptions.HTTP_PROXY_PASSWORD);
    String decodedPassword = null;
    if (encodedPassword != null) {
        decodedPassword = new String(Base64.decodeBase64(encodedPassword.getBytes()));
    }
    httpProxyPassword = new JPasswordField(decodedPassword, 20);
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    proxyPanel.add(httpProxyPassword, c);

    hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true);
    defaultEchoChar = httpProxyPassword.getEchoChar();
    hidePasswordCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                httpProxyPassword.setEchoChar(defaultEchoChar);
            } else {
                httpProxyPassword.setEchoChar((char) 0);
            }
        }
    });
    c.gridx = 1;
    c.gridy = 6;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 5, 5, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    proxyPanel.add(hidePasswordCheckbox, c);

    // Some spacing
    emptyBorderPanel.add(Box.createVerticalGlue());

    // The buttons row
    JPanel buttonPanel = new JPanel(new FlowLayout());
    emptyBorderPanel.add(buttonPanel);
    JButton okButton = new JButton(Translator.translate("ok"));
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButtonAction();
        }
    });
    buttonPanel.add(okButton);

    JButton cancelButton = new JButton(Translator.translate("cancel"));
    cancelButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            setVisible(false);
            dispose();
        }
    });
    buttonPanel.add(cancelButton);

    enableProxyComponents(proxyEnabled.booleanValue());
}

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

protected void createNotVerified() {
    GridBagConstraints c = new GridBagConstraints();
    JTextArea text = newTextArea(getNotVerifiedString());
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 1;/*from  w ww .j  av  a  2  s .  co m*/
    c.weighty = 1;
    c.anchor = GridBagConstraints.NORTHWEST;
    DETAILS.add(text, c);

    JButton button = new JButton(getVerifyString());
    button.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ev) {
            LICENSE.verify(LicenseWindow.this);
            buildDetails();
        }
    });
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.fill = GridBagConstraints.NONE;
    c.weightx = 0;
    c.weighty = 0;
    c.anchor = GridBagConstraints.SOUTHWEST;
    DETAILS.add(button, c);
}

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

/**
 * This method initializes jPanel   /*from  ww w  .  j  ava2  s. co  m*/
 *    
 * @return javax.swing.JPanel   
 */
private JPanel getJPanel() {
    if (jPanel == null) {
        GridBagConstraints gridBagConstraints12 = new GridBagConstraints();
        gridBagConstraints12.gridx = 4;
        gridBagConstraints12.gridy = 0;
        GridBagConstraints gridBagConstraints2 = new GridBagConstraints();
        gridBagConstraints2.anchor = GridBagConstraints.WEST;
        GridBagConstraints gridBagConstraints11 = new GridBagConstraints();
        gridBagConstraints11.gridx = 3;
        gridBagConstraints11.gridy = 0;
        GridBagConstraints gridBagConstraints1 = new GridBagConstraints();
        gridBagConstraints1.gridx = 2;
        gridBagConstraints1.gridy = 0;
        GridBagConstraints gridBagConstraints = new GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.anchor = GridBagConstraints.WEST;
        gridBagConstraints.gridy = 0;
        jPanel = new JPanel();
        jPanel.setLayout(new GridBagLayout());
        jPanel.add(getJButton(), gridBagConstraints2);
        jPanel.add(getJButton1(), gridBagConstraints);
        jPanel.add(getJButton2(), gridBagConstraints1);
        jPanel.add(getJButton3(), gridBagConstraints11);
        jPanel.add(getJButton4(), gridBagConstraints12);
    }
    return jPanel;
}

From source file:hr.restart.util.chart.ChartXYZ2.java

void showOptions() {

    if (optionsPanel == null) {

        catSlider = new JSlider(0, 50, iCategoryMargin);
        catSlider.setPaintLabels(true);//from  w ww .  j a  v a2  s .  c  o m
        catSlider.setPaintTicks(true);
        catSlider.setMajorTickSpacing(10);
        catSlider.setMinorTickSpacing(5);
        catSlider.setSnapToTicks(true);

        colSlider = new JSlider(-80, 20, iColumnMargin);
        colSlider.setPaintLabels(true);
        colSlider.setPaintTicks(true);
        colSlider.setMajorTickSpacing(20);
        colSlider.setMinorTickSpacing(5);
        catSlider.setSnapToTicks(true);

        colFirst = new JLabel("               ");
        colFirst.setOpaque(true);
        colFirst.setBackground(cFirst);

        colSecond = new JLabel("               ");
        colSecond.setOpaque(true);
        colSecond.setBackground(cSecond);

        JButton selFirst = new JButton("...");
        selFirst.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color ret = JColorChooser.showDialog(ChartXYZ2.this, "Boja prvog stupca", cFirst);
                if (ret != null)
                    colFirst.setBackground(ret);
            }
        });

        JButton selSecond = new JButton("...");
        selSecond.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Color ret = JColorChooser.showDialog(ChartXYZ2.this, "Boja drugog stupca", cSecond);
                if (ret != null)
                    colSecond.setBackground(ret);
            }
        });

        optionsPanel = new JPanel(new GridBagLayout());
        optionsPanel.setBorder(BorderFactory.createEmptyBorder(15, 20, 15, 20));
        GridBagConstraints c = new GridBagConstraints();
        c.weightx = 0.1;
        c.weighty = 1;
        c.gridx = 0;
        c.gridy = 0;
        c.anchor = c.LINE_START;
        c.insets = new Insets(2, 10, 2, 2);
        optionsPanel.add(new JLabel("Razmak izmeu grupa"), c);

        c.gridy = 1;
        optionsPanel.add(new JLabel("Razmak izmeu stupaca   "), c);

        c.gridy = 2;
        optionsPanel.add(new JLabel("Boja prvog stupca"), c);

        c.gridy = 3;
        optionsPanel.add(new JLabel("Boja drugog stupca"), c);

        c.weightx = 0.9;
        c.gridwidth = 2;
        c.gridx = 1;
        c.gridy = 0;
        c.fill = c.HORIZONTAL;
        optionsPanel.add(catSlider, c);

        c.gridy = 1;
        optionsPanel.add(colSlider, c);

        c.weightx = 0;
        c.gridwidth = 1;
        c.gridy = 2;
        c.fill = c.NONE;
        optionsPanel.add(colFirst, c);

        c.gridy = 3;
        optionsPanel.add(colSecond, c);

        c.weightx = 0.9;
        c.gridx = 2;
        c.gridy = 2;
        optionsPanel.add(selFirst, c);

        c.gridy = 3;
        optionsPanel.add(selSecond, c);

    } else {
        catSlider.setValue(iCategoryMargin);
        colSlider.setValue(iColumnMargin);
        colFirst.setBackground(cFirst);
        colSecond.setBackground(cSecond);
    }

    raInputDialog dlg = new raInputDialog();
    if (dlg.show(this, optionsPanel, "Opcije prikaza")) {
        iCategoryMargin = catSlider.getValue();
        iColumnMargin = colSlider.getValue();
        cFirst = colFirst.getBackground();
        cSecond = colSecond.getBackground();
        selectionChanged();
    }
}