Example usage for java.awt GridBagConstraints LINE_START

List of usage examples for java.awt GridBagConstraints LINE_START

Introduction

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

Prototype

int LINE_START

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

Click Source Link

Document

Place the component centered along the edge of its display area where lines of text would normally begin for the current ComponentOrientation .

Usage

From source file:it.cnr.icar.eric.client.ui.swing.BusinessQueryPanel.java

/**
 * Class Constructor./*from  ww w  .  j a va2s . c  o  m*/
 */
public BusinessQueryPanel(final FindParamsPanel findParamsPanel, ConfigurationType uiConfigurationType)
        throws JAXRException {
    super(findParamsPanel, uiConfigurationType);

    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    objectTypeLabel = new JLabel(resourceBundle.getString("title.objectType"), SwingConstants.LEADING);

    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(objectTypeLabel, c);
    add(objectTypeLabel);

    //TODO: SwingBoost: Localize this
    TreeNode tempTreeNode = new DefaultMutableTreeNode("loading object types...");
    objectTypeCombo = new it.cnr.icar.eric.client.ui.swing.TreeCombo(new DefaultTreeModel(tempTreeNode));

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(objectTypeCombo, c);
    add(objectTypeCombo);
    objectTypeCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String objectType = getObjectType().toString();
        }
    });

    //The caseSensitive CheckBox
    caseSensitiveCheckBox = new JCheckBox(resourceBundle.getString("title.caseSensitiveSearch"));
    caseSensitiveCheckBox.setSelected(false);
    caseSensitiveCheckBox.setEnabled(true);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(caseSensitiveCheckBox, c);
    add(caseSensitiveCheckBox);

    //The name Text
    nameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(nameLabel, c);
    add(nameLabel);

    nameText = new JTextField();
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(nameText, c);
    add(nameText);

    nameText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //The description text
    descLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(descLabel, c);
    add(descLabel);

    descText = new JTextField();
    c.gridx = 0;
    c.gridy = 6;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(descText, c);
    add(descText);

    descText.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            findParamsPanel.find();
        }
    });

    //Classifications
    classificationsLabel = new JLabel(resourceBundle.getString("title.classifications"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 7;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(classificationsLabel, c);
    add(classificationsLabel);

    classificationsList = new ClassificationsList();
    classificationsList.setEditable(true);
    classificationsList.setVisibleRowCount(3);

    JScrollPane classificationsListScrollPane = new JScrollPane(classificationsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    classificationsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 8;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(classificationsListScrollPane, c);
    add(classificationsListScrollPane);

    //Identifiers
    identifiersLabel = new JLabel(resourceBundle.getString("title.externalIdentifiers"),
            SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 9;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(identifiersLabel, c);
    add(identifiersLabel);

    extIdsList = new ExternalIdentifiersList();
    extIdsList.setEditable(true);
    extIdsList.setVisibleRowCount(3);

    JScrollPane extIdsListScrollPane = new JScrollPane(extIdsList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    extIdsListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 10;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(extIdsListScrollPane, c);
    add(extIdsListScrollPane);

    //External Links
    linksLabel = new JLabel(resourceBundle.getString("title.externalLinks"), SwingConstants.TRAILING);
    c.gridx = 0;
    c.gridy = 11;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(linksLabel, c);
    add(linksLabel);

    linksList = new ExternalLinksList();
    linksList.setEditable(true);
    linksList.setVisibleRowCount(3);

    JScrollPane linksListScrollPane = new JScrollPane(linksList);

    //Workaround for bug 740746 where very wide item resulted in too short a height
    linksListScrollPane.setMinimumSize(new Dimension(-1, 50));

    c.gridx = 0;
    c.gridy = 12;
    c.gridwidth = 2;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(linksListScrollPane, c);
    add(linksListScrollPane);

    //add listener for 'locale' bound property
    RegistryBrowser.getInstance().addPropertyChangeListener(RegistryBrowser.PROPERTY_LOCALE, this);
}

From source file:net.vanosten.dings.swing.SummaryView.java

private void initializeChartPropertiesPanel() {
    chartPropertiesP = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    GridBagConstraints gbc = new GridBagConstraints();
    chartPropertiesP.setLayout(gbl);/*ww  w .ja  v  a 2s.  c o  m*/

    TitledBorder title;
    title = BorderFactory.createTitledBorder("Chart Properties");
    chartPropertiesP.setBorder(title);

    JLabel typeL = new JLabel("Chart Type:");
    typeL.setDisplayedMnemonic("C".charAt(0));
    typeL.setLabelFor(chartTypeCB);
    JLabel emptyL = new JLabel();

    Insets vghg = new Insets(DingsSwingConstants.SP_V_G, DingsSwingConstants.SP_H_G, 0, 0);
    //----type
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    gbc.anchor = GridBagConstraints.LINE_END;
    gbc.insets = vghg;
    gbl.setConstraints(typeL, gbc);
    chartPropertiesP.add(typeL);
    //----
    gbc.gridx = 1;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbl.setConstraints(chartTypeCB, gbc);
    chartPropertiesP.add(chartTypeCB);
    //----
    gbc.gridx = 2;
    gbc.weightx = 1.0;
    gbc.fill = GridBagConstraints.HORIZONTAL;
    gbl.setConstraints(emptyL, gbc);
    chartPropertiesP.add(emptyL);
    //----chosen
    gbc.gridx = 1;
    gbc.gridy = 1;
    gbc.weightx = 0.0;
    gbc.fill = GridBagConstraints.NONE;
    gbl.setConstraints(chosenCB, gbc);
    chartPropertiesP.add(chosenCB);
}

From source file:com.socrata.datasync.ui.MetadataJobTab.java

public MetadataJobTab(MetadataJob job, JFrame containingFrame) {
    this.metadataJob = job;

    mainFrame = containingFrame;//from  ww  w  . ja v a2s  . c o m

    // build tab panel form
    //jobPanel = new JPanel(new GridLayout(0,2));
    jobPanel = new JPanel(new GridBagLayout());

    // set FlowLayouts
    FlowLayout flowLeft = new FlowLayout(FlowLayout.LEFT, 0, 0);
    FlowLayout flowRight = new FlowLayout(FlowLayout.LEFT, 0, JOB_FIELD_VGAP);

    //Dataset ID Text Field
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("Dataset ID", DATASET_ID_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 0));
    JPanel datasetIDTextFieldContainer = new JPanel(flowRight);
    datasetIDTextField = new JTextField();
    datasetIDTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    datasetIDTextFieldContainer.add(datasetIDTextField);
    jobPanel.add(datasetIDTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 0));

    //Load Metadata Button
    jobPanel.add(new JLabel(""));
    JPanel loadMetadataButtonContainer = new JPanel(flowRight);
    JButton loadMetadataButton = new JButton("Load Current Dataset Metadata");
    loadMetadataButton.addActionListener(new LoadMetadataActionListener());
    loadMetadataButtonContainer.add(loadMetadataButton);
    loadMetadataButtonContainer.add(UIUtility.generateHelpBubble(LOAD_METADATA_TIP_TEXT));
    jobPanel.add(loadMetadataButtonContainer, UIUtility.getGridBagFieldConstraints(1, 1));

    //Title Text Field
    jobPanel.add(UIUtility.generateLabelWithHelpBubble("Title", TITLE_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 2));
    JPanel titleTextFieldContainer = new JPanel(flowRight);
    titleTextField = new JTextField();
    titleTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    titleTextFieldContainer.add(titleTextField);
    jobPanel.add(titleTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 2));

    //Description Text Area
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("Description", DESCRIPTION_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 3));
    JPanel descriptionTextFieldContainer = new JPanel();
    descriptionTextArea = new JTextArea(5, 33);
    descriptionTextArea.setLineWrap(true);
    descriptionTextArea.setWrapStyleWord(true);
    JScrollPane descriptionScrollPane = new JScrollPane(descriptionTextArea);
    descriptionTextFieldContainer.add(descriptionScrollPane);
    GridBagConstraints constraints = new GridBagConstraints();
    constraints.gridx = 1;
    constraints.gridy = 3;
    constraints.weightx = 0;
    constraints.anchor = GridBagConstraints.LINE_START;
    constraints.ipadx = -10; //Not sure why, but text area was getting extra margin so left edge didn't line up with other fields        
    jobPanel.add(descriptionTextFieldContainer, constraints);

    //Category Text Field
    jobPanel.add(UIUtility.generateLabelWithHelpBubble("Category", CATEGORY_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 4));
    JPanel categoryTextFieldContainer = new JPanel(flowRight);
    categoryTextField = new JTextField();
    categoryTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    categoryTextFieldContainer.add(categoryTextField);
    jobPanel.add(categoryTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 4));

    //Tags/Keywords Text Field
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("Tags/Keywords", KEYWORDS_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 5));
    JPanel keywordsTextFieldContainer = new JPanel(flowRight);
    keywordsTextField = new JTextField();
    keywordsTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    keywordsTextFieldContainer.add(keywordsTextField);
    jobPanel.add(keywordsTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 5));

    //License Type Combo Box
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("License Type", LICENSE_TYPE_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 6));
    JPanel licenseTypeContainer = new JPanel(flowRight);
    licenseTypeComboBox = new JComboBox();
    for (LicenseType licenseType : LicenseType.values()) {
        licenseTypeComboBox.addItem(licenseType);
    }
    licenseTypeContainer.add(licenseTypeComboBox);
    jobPanel.add(licenseTypeContainer, UIUtility.getGridBagFieldConstraints(1, 6));

    //Data Provided By Text Field
    jobPanel.add(UIUtility.generateLabelWithHelpBubble("Data Provided By", DATA_PROVIDED_BY_TIP_TEXT,
            HELP_ICON_TOP_PADDING), UIUtility.getGridBagLabelConstraints(0, 7));
    JPanel dataProvidedByTextFieldContainer = new JPanel(flowRight);
    dataProvidedByTextField = new JTextField();
    dataProvidedByTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    dataProvidedByTextFieldContainer.add(dataProvidedByTextField);
    jobPanel.add(dataProvidedByTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 7));

    //Source Link Text Field
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("Source Link", SOURCE_LINK_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 8));
    JPanel sourceLinkTextFieldContainer = new JPanel(flowRight);
    sourceLinkTextField = new JTextField();
    sourceLinkTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    sourceLinkTextFieldContainer.add(sourceLinkTextField);
    jobPanel.add(sourceLinkTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 8));

    //Contact Info Text Field
    jobPanel.add(
            UIUtility.generateLabelWithHelpBubble("Contact Info", CONTACT_INFO_TIP_TEXT, HELP_ICON_TOP_PADDING),
            UIUtility.getGridBagLabelConstraints(0, 9));
    JPanel contactInfoTextFieldContainer = new JPanel(flowRight);
    contactInfoTextField = new JTextField();
    contactInfoTextField.setPreferredSize(new Dimension(JOB_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    contactInfoTextFieldContainer.add(contactInfoTextField);
    jobPanel.add(contactInfoTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 9));

    //Command to execute
    jobPanel.add(UIUtility.generateLabelWithHelpBubble("Command to execute with scheduler",
            RUN_COMMAND_TIP_TEXT, HELP_ICON_TOP_PADDING), UIUtility.getGridBagLabelConstraints(0, 10));
    JPanel runCommandTextFieldContainer = new JPanel(flowRight);
    runCommandTextField = new JTextField(DEFAULT_RUN_JOB_COMMAND);
    runCommandTextField.setPreferredSize(new Dimension(JOB_COMMAND_TEXTFIELD_WIDTH, JOB_TEXTFIELD_HEIGHT));
    runCommandTextField.setEditable(false);
    runCommandTextField.addMouseListener(new JobCommandTextFieldListener());
    runCommandTextFieldContainer.add(runCommandTextField);
    JButton copyJobCommandButton = new JButton("Copy to clipboard");
    copyJobCommandButton.addActionListener(new CopyJobCommandListener());
    runCommandTextFieldContainer.add(copyJobCommandButton);
    jobPanel.add(runCommandTextFieldContainer, UIUtility.getGridBagFieldConstraints(1, 10));

    // Load job data into fields
    populateFieldsFromJobData();

    jobTabTitleLabel = new JLabel(job.getJobFilename());

}

From source file:com.excilys.ebi.gatling.recorder.ui.component.RunningFrame.java

public RunningFrame() {

    /* Initialization of the frame */
    setTitle("Gatling Recorder - Running...");
    setMinimumSize(new Dimension(800, 640));
    setLocationRelativeTo(null);//from  w ww .j a  v a 2 s . com
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    GridBagLayout gbl = new GridBagLayout();
    setLayout(gbl);

    setIconImages(Commons.getIconList());

    /* Declaration & initialization of components */
    JButton btnClear = new JButton("Clear");
    final JButton btnStop = new JButton("Stop !");
    btnStop.setSize(120, 30);

    JScrollPane panelFilters = new JScrollPane(executedEvents);
    panelFilters.setPreferredSize(new Dimension(300, 100));

    stringRequest.setPreferredSize(new Dimension(330, 100));
    JSplitPane requestResponsePane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, new JScrollPane(stringRequest),
            new JScrollPane(stringResponse));
    final JSplitPane sp = new JSplitPane(JSplitPane.VERTICAL_SPLIT, requestResponsePane, stringRequestBody);

    JScrollPane panelHostsCertificate = new JScrollPane(requiredHostsCertificate);
    panelHostsCertificate.setPreferredSize(new Dimension(300, 100));

    /* Layout */
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.insets = new Insets(10, 5, 0, 0);

    gbc.gridx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridy = 0;
    add(new JLabel("Tag :"), gbc);

    gbc.gridx = 1;
    add(txtTag, gbc);

    gbc.gridx = 2;
    gbc.weightx = 0.5;
    add(btnTag, gbc);

    gbc.gridx = 3;
    gbc.anchor = GridBagConstraints.CENTER;
    gbc.weightx = 0.25;
    add(btnClear, gbc);

    gbc.gridx = 4;
    gbc.anchor = GridBagConstraints.LINE_END;
    add(btnStop, gbc);

    gbc.gridx = 0;
    gbc.gridy = 1;
    gbc.weightx = 0;
    gbc.anchor = GridBagConstraints.LINE_START;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(new JLabel("Executed Events:"), gbc);

    gbc.gridy = 2;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 0.20;
    gbc.fill = GridBagConstraints.BOTH;
    add(panelFilters, gbc);

    gbc.gridy = 4;
    gbc.weightx = 1;
    gbc.weighty = 0.75;
    gbc.fill = GridBagConstraints.BOTH;
    add(sp, gbc);

    gbc.gridy = 5;
    gbc.weighty = 0;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.anchor = GridBagConstraints.CENTER;
    add(new JLabel("Secured hosts requiring accepting a certificate:"), gbc);

    gbc.gridy = 6;
    gbc.weighty = 0.05;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    add(panelHostsCertificate, gbc);

    /* Listeners */
    btnTag.addActionListener(new ActionListener() {

        public void actionPerformed(ActionEvent e) {
            if (!txtTag.getText().equals(EMPTY)) {
                TagEvent tag = new TagEvent(txtTag.getText());
                events.addElement(tag.toString());
                executedEvents.ensureIndexIsVisible(events.getSize() - 1);
                listEvents.add(tag);
                txtTag.setText(EMPTY);
            }
        }
    });

    executedEvents.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (executedEvents.getSelectedIndex() >= 0) {
                Object obj = listEvents.get(executedEvents.getSelectedIndex());
                if (obj instanceof ResponseReceivedEvent) {
                    ResponseReceivedEvent event = (ResponseReceivedEvent) obj;
                    stringRequest.txt.setText(event.getRequest().toString());
                    stringResponse.txt.setText(event.getResponse().toString());
                    stringRequestBody.txt.setText(new String(event.getRequest().getContent().array()));
                } else {
                    stringRequest.txt.setText(EMPTY);
                    stringResponse.txt.setText(EMPTY);
                    stringRequestBody.txt.setText(EMPTY);
                }
            }
        }
    });

    btnClear.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            clearOldRunning();
        }
    });

    btnStop.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            saveScenario();
            proxy.shutdown();
            proxy = null;
            if (!Configuration.getInstance().isConfigurationSkipped())
                getEventBus().post(new ShowConfigurationFrameEvent());
            else
                System.exit(0);
        }
    });
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private GridBagConstraints constraintsForSecondColumnCheckbox() {
    GridBagConstraints gbc;//  w ww. j a  va 2s . co m
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.insets = new Insets(INNER_GAP, INDENT, 0, 0);
    gbc.anchor = GridBagConstraints.LINE_START;
    return gbc;
}

From source file:com.github.alexfalappa.nbspringboot.projects.initializr.BootDependenciesPanel.java

private GridBagConstraints constraintsForFirstColumnCheckbox() {
    GridBagConstraints gbc;//www .j a  va 2 s .c o  m
    gbc = new java.awt.GridBagConstraints();
    gbc.gridx = 0;
    gbc.insets = new Insets(INNER_GAP, INDENT, 0, 0);
    gbc.anchor = GridBagConstraints.LINE_START;
    return gbc;
}

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

public AccountDialog(AccountInformation account, JFrame parentWindow, boolean readOnly,
        ArrayList existingAccounts) {
    super(parentWindow, true);

    boolean addingAccount = false;

    //Request focus on Account JDialog when mouse clicked
    this.addMouseListener(new MouseAdapter() {
        public void mouseClicked(MouseEvent e) {
            if (e.getClickCount() == 1) {
                requestFocus();/*from   www  .j a  va2s. c om*/

            }
        }
    });

    // Set the title based on weather we've been opened in readonly mode and
    // weather the
    // Account passed in is empty or not
    String title = null;
    if (readOnly) {
        title = Translator.translate("viewAccount");
    } else if (!readOnly && account.getAccountName().trim().equals("")) {
        title = Translator.translate("addAccount");
        addingAccount = true;
    } else {
        title = Translator.translate("editAccount");
    }
    setTitle(title);

    this.pAccount = account;
    this.existingAccounts = existingAccounts;
    this.parentWindow = parentWindow;

    getContentPane().setLayout(new GridBagLayout());
    GridBagConstraints c = new GridBagConstraints();

    Container container = getContentPane();

    // The AccountName Row
    JLabel accountLabel = new JLabel(Translator.translate("account"));
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(accountLabel, c);

    // This panel will hold the Account field and the copy and paste
    // buttons.
    JPanel accountPanel = new JPanel(new GridBagLayout());

    accountName = new JTextField(new String(pAccount.getAccountName()), 20);
    if (readOnly) {
        accountName.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    accountPanel.add(accountName, c);
    accountName.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            accountName.selectAll();
        }
    });

    JButton acctCopyButton = new JButton();
    acctCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    acctCopyButton.setToolTipText("Copy");
    acctCopyButton.setEnabled(true);
    acctCopyButton.setMargin(new Insets(0, 0, 0, 0));
    acctCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(accountName);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    accountPanel.add(acctCopyButton, c);

    JButton acctPasteButton = new JButton();
    acctPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    acctPasteButton.setToolTipText("Paste");
    acctPasteButton.setEnabled(!readOnly);
    acctPasteButton.setMargin(new Insets(0, 0, 0, 0));
    acctPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(accountName);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    accountPanel.add(acctPasteButton, c);

    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(accountPanel, c);

    // Userid Row
    JLabel useridLabel = new JLabel(Translator.translate("userid"));
    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(useridLabel, c);

    // This panel will hold the User ID field and the copy and paste
    // buttons.
    JPanel idPanel = new JPanel(new GridBagLayout());

    userId = new JTextField(new String(pAccount.getUserId()), 20);
    if (readOnly) {
        userId.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    idPanel.add(userId, c);
    userId.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            userId.selectAll();
        }
    });

    JButton idCopyButton = new JButton();
    idCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    idCopyButton.setToolTipText("Copy");
    idCopyButton.setEnabled(true);
    idCopyButton.setMargin(new Insets(0, 0, 0, 0));
    idCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(userId);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    idPanel.add(idCopyButton, c);

    JButton idPasteButton = new JButton();
    idPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    idPasteButton.setToolTipText("Paste");
    idPasteButton.setEnabled(!readOnly);
    idPasteButton.setMargin(new Insets(0, 0, 0, 0));
    idPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(userId);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    idPanel.add(idPasteButton, c);

    c.gridx = 1;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(idPanel, c);

    // Password Row
    JLabel passwordLabel = new JLabel(Translator.translate("password"));
    c.gridx = 0;
    c.gridy = 2;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(15, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(passwordLabel, c);

    // This panel will hold the password, generate password button, copy and
    // paste buttons, and hide password checkbox
    JPanel passwordPanel = new JPanel(new GridBagLayout());

    password = new JPasswordField(new String(pAccount.getPassword()), 20);
    // allow CTRL-C on the password field
    password.putClientProperty("JPasswordField.cutCopyAllowed", Boolean.TRUE);
    password.setEditable(!readOnly);
    password.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            password.selectAll();
        }
    });
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(password, c);

    JButton generateRandomPasswordButton = new JButton(Translator.translate("generate"));
    if (readOnly) {
        generateRandomPasswordButton.setEnabled(false);
    }
    generateRandomPasswordButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent actionevent) {
            // Get the user's preference about including or not Escape
            // Characters to generated passwords
            Boolean includeEscapeChars = new Boolean(
                    Preferences.get(Preferences.ApplicationOptions.INCLUDE_ESCAPE_CHARACTERS, "true"));
            int pwLength = Preferences.getInt(Preferences.ApplicationOptions.ACCOUNT_PASSWORD_LENGTH, 8);
            String Password;

            if ((includeEscapeChars.booleanValue()) && (pwLength > 3)) {
                // Verify that the generated password satisfies the criteria
                // for strong passwords(including Escape Characters)
                do {
                    Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
                } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue())));

            } else if (!(includeEscapeChars.booleanValue()) && (pwLength > 2)) {
                // Verify that the generated password satisfies the criteria
                // for strong passwords(excluding Escape Characters)
                do {
                    Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
                } while (!(CheckPassStrong(Password, includeEscapeChars.booleanValue())));

            } else {
                // Else a weak password of 3 or less chars will be produced
                Password = GeneratePassword(pwLength, includeEscapeChars.booleanValue());
            }
            password.setText(Password);
        }
    });
    if (addingAccount) {
        generateRandomPasswordButton.doClick();
    }
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(generateRandomPasswordButton, c);

    JButton pwCopyButton = new JButton();
    pwCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    pwCopyButton.setToolTipText("Copy");
    pwCopyButton.setEnabled(true);
    pwCopyButton.setMargin(new Insets(0, 0, 0, 0));
    pwCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(password);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(pwCopyButton, c);

    JButton pwPasteButton = new JButton();
    pwPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    pwPasteButton.setToolTipText("Paste");
    pwPasteButton.setEnabled(!readOnly);
    pwPasteButton.setMargin(new Insets(0, 0, 0, 0));
    pwPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(password);
        }
    });
    c.gridx = 3;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(pwPasteButton, c);

    JCheckBox hidePasswordCheckbox = new JCheckBox(Translator.translate("hide"), true);
    defaultEchoChar = password.getEchoChar();
    hidePasswordCheckbox.setMargin(new Insets(5, 0, 5, 0));
    hidePasswordCheckbox.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent e) {
            if (e.getStateChange() == ItemEvent.SELECTED) {
                password.setEchoChar(defaultEchoChar);
            } else {
                password.setEchoChar((char) 0);
            }
        }
    });

    Boolean hideAccountPassword = new Boolean(
            Preferences.get(Preferences.ApplicationOptions.ACCOUNT_HIDE_PASSWORD, "true"));
    hidePasswordCheckbox.setSelected(hideAccountPassword.booleanValue());

    c.gridx = 0;
    c.gridy = 1;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    passwordPanel.add(hidePasswordCheckbox, c);

    c.gridx = 1;
    c.gridy = 2;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(passwordPanel, c);

    // URL Row
    JLabel urlLabel = new JLabel(Translator.translate("url"));
    c.gridx = 0;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(urlLabel, c);

    // This panel will hold the URL field and the copy and paste buttons.
    JPanel urlPanel = new JPanel(new GridBagLayout());

    url = new JTextField(new String(pAccount.getUrl()), 20);
    if (readOnly) {
        url.setEditable(false);
    }
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    urlPanel.add(url, c);
    url.addFocusListener(new FocusAdapter() {
        public void focusGained(FocusEvent e) {
            url.selectAll();
        }
    });

    final JButton urlLaunchButton = new JButton();
    urlLaunchButton.setIcon(Util.loadImage("launch-url-sm.png"));
    urlLaunchButton.setToolTipText("Launch URL");
    urlLaunchButton.setEnabled(true);
    urlLaunchButton.setMargin(new Insets(0, 0, 0, 0));
    urlLaunchButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            String urlText = url.getText();

            // Check if the selected url is null or emty and inform the user
            // via JoptioPane message
            if ((urlText == null) || (urlText.length() == 0)) {
                JOptionPane.showMessageDialog(urlLaunchButton.getParent(),
                        Translator.translate("EmptyUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);
                // Check if the selected url is a valid formated url(via
                // urlIsValid() method) and inform the user via JoptioPane
                // message
            } else if (!(urlIsValid(urlText))) {
                JOptionPane.showMessageDialog(urlLaunchButton.getParent(),
                        Translator.translate("InvalidUrlJoptionpaneMsg"),
                        Translator.translate("UrlErrorJoptionpaneTitle"), JOptionPane.WARNING_MESSAGE);
                // Call the method LaunchSelectedURL() using the selected
                // url as input
            } else {
                LaunchSelectedURL(urlText);
            }
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlLaunchButton, c);

    JButton urlCopyButton = new JButton();
    urlCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    urlCopyButton.setToolTipText("Copy");
    urlCopyButton.setEnabled(true);
    urlCopyButton.setMargin(new Insets(0, 0, 0, 0));
    urlCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextField(url);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlCopyButton, c);

    JButton urlPasteButton = new JButton();
    urlPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    urlPasteButton.setToolTipText("Paste");
    urlPasteButton.setEnabled(!readOnly);
    urlPasteButton.setMargin(new Insets(0, 0, 0, 0));
    urlPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextField(url);
        }
    });
    c.gridx = 3;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    urlPanel.add(urlPasteButton, c);

    c.gridx = 1;
    c.gridy = 3;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(urlPanel, c);

    // Notes Row
    JLabel notesLabel = new JLabel(Translator.translate("notes"));
    c.gridx = 0;
    c.gridy = 4;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    container.add(notesLabel, c);

    // This panel will hold the Notes text area and the copy and paste
    // buttons.
    JPanel notesPanel = new JPanel(new GridBagLayout());

    notes = new JTextArea(new String(pAccount.getNotes()), 10, 20);
    if (readOnly) {
        notes.setEditable(false);
    }
    notes.setLineWrap(true); // Enable line wrapping.
    notes.setWrapStyleWord(true); // Line wrap at whitespace.
    JScrollPane notesScrollPane = new JScrollPane(notes);
    c.gridx = 0;
    c.gridy = 0;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.BOTH;
    notesPanel.add(notesScrollPane, c);

    JButton notesCopyButton = new JButton();
    notesCopyButton.setIcon(Util.loadImage("copy-icon.png"));
    notesCopyButton.setToolTipText("Copy");
    notesCopyButton.setEnabled(true);
    notesCopyButton.setMargin(new Insets(0, 0, 0, 0));
    notesCopyButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            copyTextArea(notes);
        }
    });
    c.gridx = 1;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    notesPanel.add(notesCopyButton, c);

    JButton notesPasteButton = new JButton();
    notesPasteButton.setIcon(Util.loadImage("paste-icon.png"));
    notesPasteButton.setToolTipText("Paste");
    notesPasteButton.setEnabled(!readOnly);
    notesPasteButton.setMargin(new Insets(0, 0, 0, 0));
    notesPasteButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent ae) {
            pasteToTextArea(notes);
        }
    });
    c.gridx = 2;
    c.gridy = 0;
    c.anchor = GridBagConstraints.FIRST_LINE_START;
    c.insets = new Insets(0, 0, 0, 5);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.NONE;
    notesPanel.add(notesPasteButton, c);

    c.gridx = 1;
    c.gridy = 4;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(10, 10, 10, 10);
    c.weightx = 1;
    c.weighty = 1;
    c.gridwidth = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(notesPanel, c);

    // Seperator Row
    JSeparator sep = new JSeparator();
    c.gridx = 0;
    c.gridy = 5;
    c.anchor = GridBagConstraints.PAGE_END;
    c.insets = new Insets(0, 0, 0, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.HORIZONTAL;
    container.add(sep, c);

    // Button Row
    JPanel buttonPanel = new JPanel();
    JButton okButton = new JButton(Translator.translate("ok"));
    // Link Enter key to okButton
    getRootPane().setDefaultButton(okButton);
    okButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            okButtonAction();
        }
    });
    buttonPanel.add(okButton);
    if (!readOnly) {
        JButton cancelButton = new JButton(Translator.translate("cancel"));
        cancelButton.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                closeButtonAction();
            }
        });
        buttonPanel.add(cancelButton);
    }
    c.gridx = 0;
    c.gridy = 6;
    c.anchor = GridBagConstraints.PAGE_END;
    c.insets = new Insets(5, 0, 5, 0);
    c.weightx = 0;
    c.weighty = 0;
    c.gridwidth = 3;
    c.fill = GridBagConstraints.NONE;
    container.add(buttonPanel, c);
}

From source file:it.cnr.icar.eric.client.ui.swing.AdhocQuerySearchPanel.java

@SuppressWarnings({ "rawtypes", "unchecked" })
private JPanel createQuerySelectionPanel() {
    JPanel querySelectionPanel = new JPanel();
    GridBagLayout gbl = new GridBagLayout();
    querySelectionPanel.setLayout(gbl);/*from   w  w  w  . j av  a  2  s . co m*/

    //The selectQueryCombo
    selectQueryLabel = new JLabel(resourceBundle.getString("title.selectQuery"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 0;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(selectQueryLabel, c);
    querySelectionPanel.add(selectQueryLabel);

    //TODO: SwingBoost: localize this:
    selectQueryCombo = new JComboBox(new String[] { "loading queries..." });
    selectQueryCombo.addItemListener(new ItemListener() {
        public void itemStateChanged(ItemEvent ev) {
            RegistryBrowser.setWaitCursor();
            if (ev.getStateChange() == ItemEvent.DESELECTED) {
                return;
            }

            @SuppressWarnings("unused")
            String item = (String) ev.getItem();
            int index = ((JComboBox) ev.getSource()).getSelectedIndex();

            QueryType uiQueryType = queries.get(index);

            try {
                setQuery(uiQueryType);
            } catch (JAXRException e) {
                RegistryBrowser.setDefaultCursor();
                throw new UndeclaredThrowableException(e);
            }
            RegistryBrowser.setDefaultCursor();
        }
    });

    c.gridx = 0;
    c.gridy = 1;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(selectQueryCombo, c);
    querySelectionPanel.add(selectQueryCombo);

    //The nameTextField
    queryNameLabel = new JLabel(resourceBundle.getString("title.name"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 2;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryNameLabel, c);
    querySelectionPanel.add(queryNameLabel);

    queryNameText = new JTextField();
    queryNameText.setEditable(false);
    c.gridx = 0;
    c.gridy = 3;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryNameText, c);
    querySelectionPanel.add(queryNameText);

    //The description TextArea
    queryDescLabel = new JLabel(resourceBundle.getString("title.description"), SwingConstants.LEADING);
    c.gridx = 0;
    c.gridy = 4;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.0;
    c.weighty = 0.0;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.LINE_START;
    c.insets = new Insets(4, 4, 0, 4);
    gbl.setConstraints(queryDescLabel, c);
    querySelectionPanel.add(queryDescLabel);

    queryDescText = new JTextArea(4, 25);
    queryDescText.setLineWrap(true);
    queryDescText.setEditable(false);
    c.gridx = 0;
    c.gridy = 5;
    c.gridwidth = 1;
    c.gridheight = 1;
    c.weightx = 0.5;
    c.weighty = 0.5;
    c.fill = GridBagConstraints.BOTH;
    c.anchor = GridBagConstraints.LINE_END;
    c.insets = new Insets(4, 4, 4, 4);
    gbl.setConstraints(queryDescText, c);
    querySelectionPanel.add(queryDescText);

    return querySelectionPanel;
}

From source file:net.sf.taverna.t2.activities.rshell.views.RshellConfigurationPanel.java

private Component createSettingsPanel() {
    JPanel settingsPanel = new JPanel(new GridBagLayout());

    GridBagConstraints labelConstraints = new GridBagConstraints();
    labelConstraints.weightx = 0.0;// w ww.  j  a  va2s .  c  om
    labelConstraints.gridx = 0;
    labelConstraints.gridy = 0;
    labelConstraints.fill = GridBagConstraints.NONE;
    labelConstraints.anchor = GridBagConstraints.LINE_START;

    GridBagConstraints fieldConstraints = new GridBagConstraints();
    fieldConstraints.weightx = 1.0;
    fieldConstraints.gridx = 1;
    fieldConstraints.gridy = 0;
    fieldConstraints.fill = GridBagConstraints.HORIZONTAL;

    GridBagConstraints buttonConstraints = new GridBagConstraints();
    buttonConstraints.weightx = 1.0;
    buttonConstraints.gridx = 1;
    buttonConstraints.gridy = 2;
    buttonConstraints.fill = GridBagConstraints.NONE;
    buttonConstraints.anchor = GridBagConstraints.WEST;

    Dimension dimension = new Dimension(0, 0);

    hostnameField = new JTextField();
    JLabel hostnameLabel = new JLabel("Hostname");
    hostnameField.setSize(dimension);
    hostnameLabel.setSize(dimension);
    hostnameLabel.setLabelFor(hostnameField);
    JsonNode connectionSettings = getJson().path("connection");

    hostnameField.setText(connectionSettings.path("hostname").asText());

    portField = new JTextField();
    JLabel portLabel = new JLabel("Port");
    portField.setSize(dimension);
    portLabel.setSize(dimension);
    portLabel.setLabelFor(portField);
    portField.setText(
            Integer.toString(connectionSettings.path("port").asInt(RshellTemplateService.DEFAULT_PORT)));

    // "Set username and password" button
    ActionListener usernamePasswordListener = new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            if (credManagerUI == null) {
                credManagerUI = new CredentialManagerUI(credentialManager);
            }
            credManagerUI.newPasswordForService(
                    URI.create("rserve://" + hostnameField.getText() + ":" + portField.getText())); // this is used as a key for the service in Credential Manager
        }
    };
    JButton setHttpUsernamePasswordButton = new JButton("Set username and password");
    setHttpUsernamePasswordButton.setSize(dimension);
    setHttpUsernamePasswordButton.addActionListener(usernamePasswordListener);

    keepSessionAliveCheckBox = new JCheckBox("Keep Session Alive");
    keepSessionAliveCheckBox.setSelected(connectionSettings.path("keepSessionAlive")
            .asBoolean(RshellTemplateService.DEFAULT_KEEP_SESSION_ALIVE));

    settingsPanel.add(hostnameLabel, labelConstraints);
    labelConstraints.gridy++;
    settingsPanel.add(hostnameField, fieldConstraints);
    fieldConstraints.gridy++;

    settingsPanel.add(portLabel, labelConstraints);
    labelConstraints.gridy++;
    settingsPanel.add(portField, fieldConstraints);
    fieldConstraints.gridy++;

    settingsPanel.add(setHttpUsernamePasswordButton, buttonConstraints);
    buttonConstraints.gridy++;

    fieldConstraints.gridy++;
    settingsPanel.add(keepSessionAliveCheckBox, fieldConstraints);
    fieldConstraints.gridy++;

    return settingsPanel;
}