Example usage for javax.swing JLabel setBorder

List of usage examples for javax.swing JLabel setBorder

Introduction

In this page you can find the example usage for javax.swing JLabel setBorder.

Prototype

@BeanProperty(preferred = true, visualUpdate = true, description = "The component's border.")
public void setBorder(Border border) 

Source Link

Document

Sets the border of this component.

Usage

From source file:com.eviware.soapui.support.components.SimpleForm.java

public <T extends JComponent> T append(String label, T component, String alignments) {
    JLabel jlabel = null;
    if (label != null) {
        jlabel = new JLabel(label.endsWith(":") || label.isEmpty() ? label : label + ":");
        jlabel.setBorder(BorderFactory.createEmptyBorder(3, 0, 0, 0));
        if (labelFont != null) {
            jlabel.setFont(labelFont);// ww  w  .j  a  va  2 s.c o  m
        }
    }

    return append(label, jlabel, component, alignments, DEFAULT_COMPONENT_COLUMN,
            getColumnSpanToTheEnd(DEFAULT_COMPONENT_COLUMN));
}

From source file:com.diversityarrays.kdxplore.field.PlotIdTrialLayoutPane.java

@Override
public JComponent getFieldLayoutPane(FieldLayout<Integer>[] returnLayout) {
    int runLength = runLengthModel.getNumber().intValue();
    if (runLength <= 0) {
        fieldLayoutRunLengthLE_0.setText("RunLength=" + runLength);
        return fieldLayoutRunLengthLE_0;
    }//from  w ww . jav a  2s .  c  o  m

    int firstPlotId = plotIdModel.getNumber().intValue();

    PlotIdFieldLayoutProcessor layoutProcessor = new PlotIdFieldLayoutProcessor();
    FieldLayout<Integer> fieldLayout = layoutProcessor.layoutField(plotIdentSummary, odtPanel.getOrigin(),
            firstPlotId, odtPanel.getOrientation(), runLength, odtPanel.getTraversal());

    if (returnLayout != null && returnLayout.length > 0) {
        returnLayout[0] = fieldLayout;
    }

    Border insideBorder = new LineBorder(Color.BLACK);
    Border outsideBorder = new EmptyBorder(1, 1, 1, 1);
    Border border = new CompoundBorder(outsideBorder, insideBorder);

    GridLayout gridLayout = new GridLayout(fieldLayout.ysize, fieldLayout.xsize);
    if (DEBUG) {
        System.out.println(
                "GridLayout( rows=" + gridLayout.getRows() + " , cols=" + gridLayout.getColumns() + ")");
    }

    fieldLayoutRunLengthGT_0.setLayout(gridLayout);

    fieldLayoutRunLengthGT_0.removeAll();
    for (int y = 0; y < fieldLayout.ysize; ++y) {
        for (int x = 0; x < fieldLayout.xsize; ++x) {
            Integer plotId = fieldLayout.cells[y][x];

            String label_s;
            if (plotId == null) {
                label_s = ".";
            } else {
                PlotName plotName = plotNameByPlotId.get(plotId);
                if (plotName == null) {
                    label_s = "-";
                } else {
                    //s = "P_" + plotId + ":" + x + "," + y;
                    StringBuilder sb = new StringBuilder("P_");
                    sb.append(plotName.getPlotId());
                    Integer xx = plotName.getX();
                    Integer yy = plotName.getY();

                    if (xx != null || yy != null) {
                        sb.append(": ");
                        if (xx != null) {
                            sb.append(xx);
                        }
                        sb.append(",");
                        if (yy != null) {
                            sb.append(yy);
                        }
                    }
                    label_s = sb.toString();
                }
            }
            JLabel label = new JLabel("<HTML><BR>" + label_s + "<BR>&nbsp;");
            label.setHorizontalAlignment(SwingConstants.CENTER);
            label.setBorder(border);
            fieldLayoutRunLengthGT_0.add(label);
        }
    }

    return fieldLayoutRunLengthGT_0;
}

From source file:edu.harvard.i2b2.query.QueryTopPanel.java

public void addPanel() {
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }/*from   www.j  a  va2s .  co m*/
    });

    //jPanel1.add(label);
    //label.setBounds(rightmostPosition, 90, 30, 18);

    QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1),
            this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181, 150));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, null, rightmostPosition + 5 + 180);

    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
}

From source file:edu.harvard.i2b2.query.QueryTopPanel.java

private void jMorePanelsButtonActionPerformed(java.awt.event.ActionEvent evt) {
    if (dataModel.hasEmptyPanels()) {
        JOptionPane.showMessageDialog(this, "Please use an existing empty panel before adding a new one.");
        return;/*from w  w w .j  a  v  a 2 s .  co m*/
    }
    int rightmostPosition = dataModel.lastLabelPosition();
    JLabel label = new JLabel();
    label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
    label.setText("and");
    label.setToolTipText("Click to change the relationship");
    label.setBorder(javax.swing.BorderFactory.createEtchedBorder());
    label.addMouseListener(new java.awt.event.MouseAdapter() {
        public void mouseClicked(java.awt.event.MouseEvent evt) {
            jAndOrLabelMouseClicked(evt);
        }
    });

    //jPanel1.add(label);
    //label.setBounds(rightmostPosition, 90, 30, 18);

    QueryConceptTreePanel panel = new QueryConceptTreePanel("Group " + (dataModel.getCurrentPanelCount() + 1),
            this);
    jPanel1.add(panel);
    panel.setBounds(rightmostPosition + 5, 0, 180, getParent().getHeight() - 100);
    jPanel1.setPreferredSize(new Dimension(rightmostPosition + 5 + 181, getHeight() - 100));
    jScrollPane4.setViewportView(jPanel1);

    dataModel.addPanel(panel, label, rightmostPosition + 5 + 180);

    /*System.out.println(jScrollPane4.getViewport().getExtentSize().width+":"+
     jScrollPane4.getViewport().getExtentSize().height);
    System.out.println(jScrollPane4.getHorizontalScrollBar().getVisibleRect().width+":"
     +jScrollPane4.getHorizontalScrollBar().getVisibleRect().height);
    System.out.println(jScrollPane4.getHorizontalScrollBar().getVisibleAmount());
    System.out.println(jScrollPane4.getHorizontalScrollBar().getValue());*/
    jScrollPane4.getHorizontalScrollBar().setValue(jScrollPane4.getHorizontalScrollBar().getMaximum());
    jScrollPane4.getHorizontalScrollBar().setUnitIncrement(40);
    //this.jScrollPane4.removeAll();
    //this.jScrollPane4.setViewportView(jPanel1);
    //revalidate();
    //jScrollPane3.setBounds(420, 0, 170, 300);
    //jScrollPane4.setBounds(20, 35, 335, 220);
    resizePanels(getParent().getWidth(), getParent().getHeight());
}

From source file:com.diversityarrays.kdxplore.boxplot.BoxPlotPanel.java

private Box generateControls() {

    for (JCheckBox jcb : Arrays.asList(showOutliers, showMean, showMedian)) {
        ActionListener optionsActionListener = new ActionListener() {
            @Override//from  www .ja  v a  2 s .c o m
            public void actionPerformed(ActionEvent e) {
                generateGraph(Why.OPTION_CHANGED);
                setSpinnerRanges();
            }
        };
        jcb.addActionListener(optionsActionListener);
        jcb.setSelected(true);
    }

    JLabel infoLabel = new JLabel(Msg.LABEL_SHOW_PARAMETERS());
    infoLabel.setBorder(new EmptyBorder(3, 3, 3, 3));

    Box hbox = Box.createHorizontalBox();
    hbox.add(syncedOption);
    hbox.add(minSpinner);
    hbox.add(new JLabel(" - ")); //$NON-NLS-1$
    hbox.add(maxSpinner);
    hbox.add(infoLabel);
    hbox.add(showOutliers);
    hbox.add(showMean);
    hbox.add(showMedian);

    return hbox;
}

From source file:net.sf.taverna.t2.workbench.cagrid.CaGridComponent.java

private void addResultPanel() {
    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;/*from w w w. j a v a 2s .co  m*/
    c.gridy = ++row;
    c.fill = GridBagConstraints.BOTH;
    c.weightx = 0.01;
    c.weighty = 0.01;
    c.anchor = GridBagConstraints.SOUTHEAST;
    c.gridwidth = GridBagConstraints.REMAINDER;
    resultPanel = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    resultPanel.setDividerLocation(200);
    resultPanel.setBorder(null);
    runListModel = new DefaultListModel();
    runList = new JList(runListModel);
    runList.setBorder(new EmptyBorder(5, 5, 5, 5));
    runList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    runListPanel = new JPanel(new BorderLayout());
    runListPanel.setBorder(LineBorder.createGrayLineBorder());

    JLabel worklflowRunsLabel = new JLabel("Workflow Runs");
    worklflowRunsLabel.setBorder(new EmptyBorder(5, 5, 5, 5));
    removeCaGridRunsButton = new JButton("Remove"); // button to remove previous workflow runs
    removeCaGridRunsButton.setAlignmentX(JComponent.RIGHT_ALIGNMENT);
    removeCaGridRunsButton.setEnabled(false);
    removeCaGridRunsButton.setToolTipText("Remove caGrid run(s)");
    removeCaGridRunsButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            int[] selected = runList.getSelectedIndices();
            for (int i = selected.length - 1; i >= 0; i--) {
                CaGridRun cr = (CaGridRun) runListModel.get(selected[i]);

                //delete the EPR file
                File file = new File(new File(System.getProperty("user.home")), cr.workflowid + ".epr");
                file.delete();
                System.out.println(cr.workflowid + ".epr deleted");
                runListModel.remove(selected[i]);
            }
            // Set the first item as selected - if there is one
            if (runListModel.size() > 0) {
                runList.setSelectedIndex(0);
            } else {
                resultText.setText("");
                resultText.revalidate();

            }
        }
    });
    runListPanel.add(worklflowRunsLabel, BorderLayout.NORTH);
    runListPanel.add(removeCaGridRunsButton, BorderLayout.BEFORE_FIRST_LINE);

    JScrollPane scrollPane = new JScrollPane(runList);
    scrollPane.setBorder(null);
    runListPanel.add(scrollPane, BorderLayout.CENTER);
    // loadWorkflowRunsFromStoredEPRFiles(): add CaGridRun to runList for each EPR
    // add two buttons: remove and refresh status
    runList.addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent e) {
            if (!e.getValueIsAdjusting()) {
                Object selection = runList.getSelectedValue();
                if (selection instanceof CaGridRun) {
                    removeCaGridRunsButton.setEnabled(true);
                    CaGridRun dataflowRun = (CaGridRun) selection;
                    // update status and refresh outputPanel
                    String resultDisplayString = updateResultDisplayString(dataflowRun);
                    resultText.setText(resultDisplayString);
                    resultText.setLineWrap(true);
                    resultText.setEditable(false);
                    outputPanel.revalidate();
                    revalidate();
                } else {
                    removeCaGridRunsButton.setEnabled(false);
                    revalidate();

                }
            }
        }
    });

    resultPanel.setTopComponent(runListPanel);

    //each output should be a (xml) string
    outputPanel = new JScrollPane();

    resultText = new JTextArea();
    outputPanel = new JScrollPane(resultText, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    //outputPanel = new JPanel(new BorderLayout());
    outputPanel.setBorder(LineBorder.createGrayLineBorder());
    outputPanel.setBackground(Color.WHITE);
    //outputPanel.add(new JLabel("Workflow Execution Outputs shows here.", JLabel.CENTER), null);
    resultPanel.setBottomComponent(outputPanel);
    add(resultPanel, c);

    //add runComponent to the GUI
    ArrayList<CaGridRun> loadedRunList = loadWorkflowRunsFromStoredEPRFiles(null,
            (String) services.getSelectedItem());
    if (loadedRunList != null) {
        for (int m = 0; m < loadedRunList.size(); m++) {
            CaGridRun cr = (CaGridRun) loadedRunList.get(m);
            runListModel.add(0, cr);
        }
        System.out.println(loadedRunList.size() + " EPR loaded.");
        runList.setSelectedIndex(0);
    }

}

From source file:com.apatar.ui.JPublishToApatarDialog.java

private void createDialog() {

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();

    this.setLayout(gridbag);

    c.gridwidth = GridBagConstraints.REMAINDER;
    c.weightx = 1.0;/*w w  w  . jav  a2s  .c o  m*/
    c.weighty = 0.0;
    c.fill = GridBagConstraints.HORIZONTAL;
    //c.insets = new Insets(5, 5, 5, 5);

    JPanel panelLogin = new JPanel();
    panelLogin.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelLogin.setLayout(new BoxLayout(panelLogin, BoxLayout.X_AXIS));
    panelLogin.add(new JLabel("User Name"));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(username);
    username.setComponentPopupMenu(new JDefaultContextMenu(username));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(new JLabel("Password"));
    panelLogin.add(Box.createHorizontalStrut(5));
    panelLogin.add(password);

    JPanel panelForgotPassLink = new JPanel();
    panelForgotPassLink.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelForgotPassLink.setLayout(new BoxLayout(panelForgotPassLink, BoxLayout.X_AXIS));
    panelForgotPassLink.add(new JLabel("Lost your password? "));
    panelForgotPassLink.add(Box.createHorizontalStrut(5));
    panelForgotPassLink.add(forgotPassLinkLabel);

    forgotPassLinkLabel.setFont(UiUtils.NORMAL_SIZE_12_FONT);
    forgotPassLinkLabel.addMouseListener(new MouseHyperLinkEvent());
    forgotPassLinkLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    forgotPassLinkLabel.setText(
            "<html><a href='http://www.apatarforge.org/profile/lostpassword.html'>Click here to retrieve it</a></html>");

    JPanel panelFile = new JPanel();
    panelFile.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelFile.setLayout(new BoxLayout(panelFile, BoxLayout.X_AXIS));
    panelFile.add(selectFromFile);
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(new JLabel("New File "));
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(nameFile);
    panelFile.add(Box.createHorizontalStrut(5));
    panelFile.add(browse);
    nameFile.setEnabled(false);
    nameFile.setComponentPopupMenu(new JDefaultContextMenu(nameFile));
    browse.setEnabled(false);

    JPanel panelLocation = new JPanel();
    panelLocation.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelLocation.setLayout(new BoxLayout(panelLocation, BoxLayout.X_AXIS));
    panelLocation.add(new JLabel("Suggest Location:"));
    panelLocation.add(Box.createHorizontalStrut(5));
    panelLocation.add(location);

    JPanel panelDMName = new JPanel();
    panelDMName.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMName.setLayout(new BoxLayout(panelDMName, BoxLayout.X_AXIS));
    JLabel datamapNameLabel = new JLabel("DataMap Name:");
    datamapNameLabel.setBorder(new EmptyBorder(0, 0, 0, 10));
    panelDMName.add(datamapNameLabel);
    panelDMName.add(Box.createHorizontalStrut(5));
    panelDMName.add(dataMapName);
    dataMapName.setComponentPopupMenu(new JDefaultContextMenu(dataMapName));

    JPanel panelDMDescription = new JPanel();
    panelDMDescription.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMDescription.setLayout(new BoxLayout(panelDMDescription, BoxLayout.X_AXIS));
    panelDMDescription.add(new JLabel("DataMap Description (16000 Chars)"));
    panelDMDescription.add(Box.createHorizontalStrut(5));
    //JScrollPane scroll = new JScrollPane(dataMapDescription);
    //scroll.setSize(300, 50);
    dataMapDescription.setLineWrap(true);
    dataMapDescription.setWrapStyleWord(true);
    panelDMDescription.add(new JScrollPane(dataMapDescription));

    JPanel panelDMShortDescription = new JPanel();
    panelDMShortDescription.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelDMShortDescription.setLayout(new BoxLayout(panelDMShortDescription, BoxLayout.X_AXIS));
    JLabel labelShort = new JLabel("Short Description:");
    labelShort.setBorder(new EmptyBorder(0, 0, 0, 85));
    panelDMShortDescription.add(labelShort);
    panelDMShortDescription.add(Box.createHorizontalStrut(5));
    shortDescription.setLineWrap(true);
    shortDescription.setWrapStyleWord(true);
    panelDMShortDescription.add(new JScrollPane(shortDescription));
    setEnableShortDescription(false);

    // -------------

    JPanel panelTitleForTags = new JPanel();
    panelTitleForTags.setBorder(new EmptyBorder(10, 10, 0, 10));
    panelTitleForTags.setLayout(new BoxLayout(panelTitleForTags, BoxLayout.X_AXIS));
    panelTitleForTags.add(new JLabel("Add tags associated with your DataMap:"));

    // -------------

    JPanel panelListAddedTags = new JPanel();
    panelListAddedTags.setBorder(new EmptyBorder(0, 10, 10, 10));
    panelListAddedTags.setLayout(new BoxLayout(panelListAddedTags, BoxLayout.X_AXIS));

    // --
    JPanel panelFrom = new JPanel();
    panelFrom.setLayout(new BoxLayout(panelFrom, BoxLayout.Y_AXIS));
    JPanel panelMiddle = new JPanel();
    panelMiddle.setLayout(new BoxLayout(panelMiddle, BoxLayout.X_AXIS));
    JPanel panelTo = new JPanel();
    panelTo.setLayout(new BoxLayout(panelTo, BoxLayout.Y_AXIS));

    // --
    JPanel panelAddNewTag = new JPanel();
    panelAddNewTag.setLayout(new BoxLayout(panelAddNewTag, BoxLayout.X_AXIS));
    panelAddNewTag.add(new JLabel("Add new tag:"));
    panelAddNewTag.add(Box.createHorizontalStrut(5));
    textfieldAddNewTag = new JTextField();
    textfieldAddNewTag.setComponentPopupMenu(new JDefaultContextMenu(textfieldAddNewTag));
    panelAddNewTag.add(textfieldAddNewTag);
    panelAddNewTag.add(Box.createHorizontalStrut(5));
    JButton buttonAddTag = new JButton("Add");
    buttonAddTag.addActionListener(addNewTagMouseListener);
    panelAddNewTag.add(buttonAddTag);

    // --
    JPanel panelDeleteTags = new JPanel();
    panelDeleteTags.setLayout(new BoxLayout(panelDeleteTags, BoxLayout.X_AXIS));

    panelDeleteTags.add(new JLabel("Delete selected tag(s):"));
    panelDeleteTags.add(Box.createHorizontalStrut(5));
    JButton buttonDeleteTag = new JButton("Delete");
    buttonDeleteTag.addActionListener(deleteTagMouseListener);
    panelDeleteTags.add(buttonDeleteTag);
    panelDeleteTags.add(new JPanel());

    // --

    JButton moveTag = new JButton(UiUtils.ARROW_ICON);
    moveTag.addActionListener(addTagsMouseListener);
    panelMiddle.add(moveTag);

    tblModelFrom = new DefaultTableModel();
    tblModelTo = new DefaultTableModel();
    tblModelFrom.addColumn("Tag Name");
    tblModelTo.addColumn("Tag Name");

    tagsTableFrom = new JTable(tblModelFrom);
    tagsTableTo = new JTable(tblModelTo);

    tagsTableFrom.setOpaque(false);
    tagsTableFrom.setBackground(null);
    tagsTableFrom.setBorder(null);
    tagsTableFrom.setShowGrid(false);

    tagsTableTo.setOpaque(false);
    tagsTableTo.setBackground(null);
    tagsTableTo.setBorder(null);
    tagsTableTo.setShowGrid(false);

    tagsTableFrom.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField()));
    tagsTableTo.getColumn("Tag Name").setCellEditor(new CellEditor(new JTextField()));

    fillTableTags();

    tagsTableFrom.setComponentPopupMenu(new JDefaultContextMenu(tagsTableFrom));
    tagsTableTo.setComponentPopupMenu(new JDefaultContextMenu(tagsTableTo));

    JScrollPane srollPane = new JScrollPane(tagsTableFrom);
    srollPane.setBorder(null);

    JScrollPane srollPane2 = new JScrollPane(tagsTableTo);
    srollPane.setBorder(null);

    panelFrom.add(srollPane);
    panelFrom.add(Box.createVerticalStrut(5));
    panelFrom.add(panelAddNewTag);

    panelTo.add(srollPane2);
    panelTo.add(Box.createVerticalStrut(5));
    panelTo.add(panelDeleteTags);

    panelListAddedTags.add(panelFrom);
    panelListAddedTags.add(Box.createHorizontalStrut(5));
    panelListAddedTags.add(panelMiddle);
    panelListAddedTags.add(Box.createHorizontalStrut(5));
    panelListAddedTags.add(panelTo);

    // -------

    JPanel panelButton = new JPanel();
    panelButton.setLayout(new BoxLayout(panelButton, BoxLayout.X_AXIS));
    panelButton.add(Box.createHorizontalGlue());
    panelButton.add(bOk);
    panelButton.add(Box.createHorizontalStrut(5));
    panelButton.add(bCancel);
    panelButton.add(Box.createHorizontalStrut(5));

    ComponentBuilder.makeComponent(new JCommentPanel(), gridbag, c, getContentPane());

    ComponentBuilder.makeComponent(panelLogin, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelForgotPassLink, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelFile, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelLocation, gridbag, c, getContentPane());
    ComponentBuilder.makeComponent(panelDMName, gridbag, c, getContentPane());

    c.fill = GridBagConstraints.BOTH;

    c.weighty = 2.0;
    ComponentBuilder.makeComponent(panelDMDescription, gridbag, c, getContentPane());

    c.weighty = 0.0;
    ComponentBuilder.makeComponent(autoGenerateShortDescription, gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelDMShortDescription, gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelTitleForTags, gridbag, c, getContentPane());

    c.weighty = 3.0;
    ComponentBuilder.makeComponent(panelListAddedTags, gridbag, c, getContentPane());

    c.weighty = 0.0;
    ComponentBuilder.makeComponent(new JSeparator(), gridbag, c, getContentPane());

    c.weighty = 1.0;
    ComponentBuilder.makeComponent(panelButton, gridbag, c, getContentPane());
}

From source file:net.sf.jabref.wizard.auximport.gui.FromAuxDialog.java

private void jbInit() {
    JPanel panel1 = new JPanel();

    panel1.setLayout(new BorderLayout());
    selectInDBButton.setText(Localization.lang("Select"));
    selectInDBButton.setEnabled(false);//from www  .j  av a  2s  . c  om
    selectInDBButton.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent arg0) {
            FromAuxDialog.this.select_actionPerformed();
        }
    });
    generateButton.setText(Localization.lang("Generate"));
    generateButton.setEnabled(false);
    generateButton.addActionListener(new FromAuxDialog_generate_actionAdapter(this));
    cancelButton.setText(Localization.lang("Cancel"));
    cancelButton.addActionListener(new FromAuxDialog_Cancel_actionAdapter(this));
    parseButton.setText(Localization.lang("Parse"));
    parseButton.addActionListener(new FromAuxDialog_parse_actionAdapter(this));

    initPanels();

    // insert the buttons
    ButtonBarBuilder bb = new ButtonBarBuilder();
    JPanel buttonPanel = bb.getPanel();
    buttonPanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));

    bb.addGlue();
    bb.addButton(parseButton);
    bb.addRelatedGap();
    bb.addButton(selectInDBButton);
    bb.addButton(generateButton);
    bb.addButton(cancelButton);
    bb.addGlue();
    this.setModal(true);
    this.setResizable(true);
    this.setTitle(Localization.lang("AUX file import"));
    JLabel desc = new JLabel("<html><h3>" + Localization.lang("AUX file import") + "</h3><p>"
            + Localization.lang("This feature generates a new database based on which entries "
                    + "are needed in an existing LaTeX document.")
            + "</p>" + "<p>"
            + Localization.lang("You need to select one of your open databases from which to choose "
                    + "entries, as well as the AUX file produced by LaTeX when compiling your document.")
            + "</p></html>");
    desc.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    panel1.add(desc, BorderLayout.NORTH);

    JPanel centerPane = new JPanel(new BorderLayout());
    centerPane.add(buttons, BorderLayout.NORTH);
    centerPane.add(statusPanel, BorderLayout.CENTER);

    getContentPane().add(panel1, BorderLayout.NORTH);
    getContentPane().add(centerPane, BorderLayout.CENTER);
    getContentPane().add(buttonPanel, BorderLayout.SOUTH);

    // Key bindings:
    ActionMap am = statusPanel.getActionMap();
    InputMap im = statusPanel.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
    im.put(Globals.getKeyPrefs().getKey(KeyBinding.CLOSE_DIALOG), "close");
    am.put("close", new AbstractAction() {
        @Override
        public void actionPerformed(ActionEvent e) {
            dispose();
        }
    });

}

From source file:gate.gui.docview.AnnotationStack.java

/**
 * Draw the annotation stack in a JPanel with a GridBagLayout.
 *//* w  w  w . jav  a2 s.c  o m*/
public void drawStack() {

    // clear the panel
    removeAll();

    boolean textTooLong = text.length() > maxTextLength;
    int upperBound = text.length() - (maxTextLength / 2);

    GridBagConstraints gbc = new GridBagConstraints();
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.fill = GridBagConstraints.BOTH;

    /**********************
     * First row of text *
     *********************/

    gbc.gridwidth = 1;
    gbc.insets = new java.awt.Insets(10, 10, 10, 10);
    JLabel labelTitle = new JLabel("Context");
    labelTitle.setOpaque(true);
    labelTitle.setBackground(Color.WHITE);
    labelTitle.setBorder(new CompoundBorder(
            new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250), new Color(250, 250, 250).darker()),
            new EmptyBorder(new Insets(0, 2, 0, 2))));
    labelTitle.setToolTipText("Expression and its context.");
    add(labelTitle, gbc);
    gbc.insets = new java.awt.Insets(10, 0, 10, 0);

    int expressionStart = contextBeforeSize;
    int expressionEnd = text.length() - contextAfterSize;

    // for each character
    for (int charNum = 0; charNum < text.length(); charNum++) {

        gbc.gridx = charNum + 1;
        if (textTooLong) {
            if (charNum == maxTextLength / 2) {
                // add ellipsis dots in case of a too long text displayed
                add(new JLabel("..."), gbc);
                // skip the middle part of the text if too long
                charNum = upperBound + 1;
                continue;
            } else if (charNum > upperBound) {
                gbc.gridx -= upperBound - (maxTextLength / 2) + 1;
            }
        }

        // set the text and color of the feature value
        JLabel label = new JLabel(text.substring(charNum, charNum + 1));
        if (charNum >= expressionStart && charNum < expressionEnd) {
            // this part is matched by the pattern, color it
            label.setBackground(new Color(240, 201, 184));
        } else {
            // this part is the context, no color
            label.setBackground(Color.WHITE);
        }
        label.setOpaque(true);

        // get the word from which belongs the current character charNum
        int start = text.lastIndexOf(" ", charNum);
        int end = text.indexOf(" ", charNum);
        String word = text.substring((start == -1) ? 0 : start, (end == -1) ? text.length() : end);
        // add a mouse listener that modify the query
        label.addMouseListener(textMouseListener.createListener(word));
        add(label, gbc);
    }

    /************************************
     * Subsequent rows with annotations *
     ************************************/

    // for each row to display
    for (StackRow stackRow : stackRows) {
        String type = stackRow.getType();
        String feature = stackRow.getFeature();
        if (feature == null) {
            feature = "";
        }
        String shortcut = stackRow.getShortcut();
        if (shortcut == null) {
            shortcut = "";
        }

        gbc.gridy++;
        gbc.gridx = 0;
        gbc.gridwidth = 1;
        gbc.insets = new Insets(0, 0, 3, 0);

        // add the header of the row
        JLabel annotationTypeAndFeature = new JLabel();
        String typeAndFeature = type + (feature.equals("") ? "" : ".") + feature;
        annotationTypeAndFeature.setText(!shortcut.equals("") ? shortcut
                : stackRow.getSet() != null ? stackRow.getSet() + "#" + typeAndFeature : typeAndFeature);
        annotationTypeAndFeature.setOpaque(true);
        annotationTypeAndFeature.setBackground(Color.WHITE);
        annotationTypeAndFeature
                .setBorder(new CompoundBorder(new EtchedBorder(EtchedBorder.LOWERED, new Color(250, 250, 250),
                        new Color(250, 250, 250).darker()), new EmptyBorder(new Insets(0, 2, 0, 2))));
        if (feature.equals("")) {
            annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type));
        } else {
            annotationTypeAndFeature.addMouseListener(headerMouseListener.createListener(type, feature));
        }
        gbc.insets = new java.awt.Insets(0, 10, 3, 10);
        add(annotationTypeAndFeature, gbc);
        gbc.insets = new java.awt.Insets(0, 0, 3, 0);

        // add all annotations for this row
        HashMap<Integer, TreeSet<Integer>> gridSet = new HashMap<Integer, TreeSet<Integer>>();
        int gridyMax = gbc.gridy;
        for (StackAnnotation ann : stackRow.getAnnotations()) {
            gbc.gridx = ann.getStartNode().getOffset().intValue() - expressionStartOffset + contextBeforeSize
                    + 1;
            gbc.gridwidth = ann.getEndNode().getOffset().intValue() - ann.getStartNode().getOffset().intValue();
            if (gbc.gridx == 0) {
                // column 0 is already the row header
                gbc.gridwidth -= 1;
                gbc.gridx = 1;
            } else if (gbc.gridx < 0) {
                // annotation starts before displayed text
                gbc.gridwidth += gbc.gridx - 1;
                gbc.gridx = 1;
            }
            if (gbc.gridx + gbc.gridwidth > text.length()) {
                // annotation ends after displayed text
                gbc.gridwidth = text.length() - gbc.gridx + 1;
            }
            if (textTooLong) {
                if (gbc.gridx > (upperBound + 1)) {
                    // x starts after the hidden middle part
                    gbc.gridx -= upperBound - (maxTextLength / 2) + 1;
                } else if (gbc.gridx > (maxTextLength / 2)) {
                    // x starts in the hidden middle part
                    if (gbc.gridx + gbc.gridwidth <= (upperBound + 3)) {
                        // x ends in the hidden middle part
                        continue; // skip the middle part of the text
                    } else {
                        // x ends after the hidden middle part
                        gbc.gridwidth -= upperBound - gbc.gridx + 2;
                        gbc.gridx = (maxTextLength / 2) + 2;
                    }
                } else {
                    // x starts before the hidden middle part
                    if (gbc.gridx + gbc.gridwidth < (maxTextLength / 2)) {
                        // x ends before the hidden middle part
                        // do nothing
                    } else if (gbc.gridx + gbc.gridwidth < upperBound) {
                        // x ends in the hidden middle part
                        gbc.gridwidth = (maxTextLength / 2) - gbc.gridx + 1;
                    } else {
                        // x ends after the hidden middle part
                        gbc.gridwidth -= upperBound - (maxTextLength / 2) + 1;
                    }
                }
            }
            if (gbc.gridwidth == 0) {
                gbc.gridwidth = 1;
            }

            JLabel label = new JLabel();
            Object object = ann.getFeatures().get(feature);
            String value = (object == null) ? " " : Strings.toString(object);
            if (value.length() > maxFeatureValueLength) {
                // show the full text in the tooltip
                label.setToolTipText((value.length() > 500)
                        ? "<html><textarea rows=\"30\" cols=\"40\" readonly=\"readonly\">"
                                + value.replaceAll("(.{50,60})\\b", "$1\n") + "</textarea></html>"
                        : ((value.length() > 100)
                                ? "<html><table width=\"500\" border=\"0\" cellspacing=\"0\">" + "<tr><td>"
                                        + value.replaceAll("\n", "<br>") + "</td></tr></table></html>"
                                : value));
                if (stackRow.getCrop() == CROP_START) {
                    value = "..." + value.substring(value.length() - maxFeatureValueLength - 1);
                } else if (stackRow.getCrop() == CROP_END) {
                    value = value.substring(0, maxFeatureValueLength - 2) + "...";
                } else {// cut in the middle
                    value = value.substring(0, maxFeatureValueLength / 2) + "..."
                            + value.substring(value.length() - (maxFeatureValueLength / 2));
                }
            }
            label.setText(value);
            label.setBackground(AnnotationSetsView.getColor(stackRow.getSet(), ann.getType()));
            label.setBorder(BorderFactory.createLineBorder(Color.BLACK, 1));
            label.setOpaque(true);

            label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type,
                    String.valueOf(ann.getId())));

            // show the feature values in the tooltip
            if (!ann.getFeatures().isEmpty()) {
                String width = (Strings.toString(ann.getFeatures()).length() > 100) ? "500" : "100%";
                String toolTip = "<html><table width=\"" + width
                        + "\" border=\"0\" cellspacing=\"0\" cellpadding=\"4\">";
                Color color = (Color) UIManager.get("ToolTip.background");
                float[] hsb = Color.RGBtoHSB(color.getRed(), color.getGreen(), color.getBlue(), null);
                color = Color.getHSBColor(hsb[0], hsb[1], Math.max(0f, hsb[2] - hsb[2] * 0.075f)); // darken the color
                String hexColor = Integer.toHexString(color.getRed()) + Integer.toHexString(color.getGreen())
                        + Integer.toHexString(color.getBlue());
                boolean odd = false; // alternate background color every other row

                List<Object> features = new ArrayList<Object>(ann.getFeatures().keySet());
                //sort the features into alphabetical order
                Collections.sort(features, new Comparator<Object>() {
                    @Override
                    public int compare(Object o1, Object o2) {
                        return o1.toString().compareToIgnoreCase(o2.toString());
                    }
                });

                for (Object key : features) {
                    String fv = Strings.toString(ann.getFeatures().get(key));
                    toolTip += "<tr align=\"left\"" + (odd ? " bgcolor=\"#" + hexColor + "\"" : "")
                            + "><td><strong>" + key + "</strong></td><td>"
                            + ((fv.length() > 500)
                                    ? "<textarea rows=\"20\" cols=\"40\" cellspacing=\"0\">" + StringEscapeUtils
                                            .escapeHtml(fv.replaceAll("(.{50,60})\\b", "$1\n")) + "</textarea>"
                                    : StringEscapeUtils.escapeHtml(fv).replaceAll("\n", "<br>"))
                            + "</td></tr>";
                    odd = !odd;
                }
                label.setToolTipText(toolTip + "</table></html>");
            } else {
                label.setToolTipText("No features.");
            }

            if (!feature.equals("")) {
                label.addMouseListener(annotationMouseListener.createListener(stackRow.getSet(), type, feature,
                        Strings.toString(ann.getFeatures().get(feature)), String.valueOf(ann.getId())));
            }
            // find the first empty row span for this annotation
            int oldGridy = gbc.gridy;
            for (int y = oldGridy; y <= (gridyMax + 1); y++) {
                // for each cell of this row where spans the annotation
                boolean xSpanIsEmpty = true;
                for (int x = gbc.gridx; (x < (gbc.gridx + gbc.gridwidth)) && xSpanIsEmpty; x++) {
                    xSpanIsEmpty = !(gridSet.containsKey(x) && gridSet.get(x).contains(y));
                }
                if (xSpanIsEmpty) {
                    gbc.gridy = y;
                    break;
                }
            }
            // save the column x and row y of the current value
            TreeSet<Integer> ts;
            for (int x = gbc.gridx; x < (gbc.gridx + gbc.gridwidth); x++) {
                ts = gridSet.get(x);
                if (ts == null) {
                    ts = new TreeSet<Integer>();
                }
                ts.add(gbc.gridy);
                gridSet.put(x, ts);
            }
            add(label, gbc);
            gridyMax = Math.max(gridyMax, gbc.gridy);
            gbc.gridy = oldGridy;
        }

        // add a button at the end of the row
        gbc.gridwidth = 1;
        if (stackRow.getLastColumnButton() != null) {
            // last cell of the row
            gbc.gridx = Math.min(text.length(), maxTextLength) + 1;
            gbc.insets = new Insets(0, 10, 3, 0);
            gbc.fill = GridBagConstraints.NONE;
            gbc.anchor = GridBagConstraints.WEST;
            add(stackRow.getLastColumnButton(), gbc);
            gbc.insets = new Insets(0, 0, 3, 0);
            gbc.fill = GridBagConstraints.BOTH;
            gbc.anchor = GridBagConstraints.CENTER;
        }

        // set the new gridy to the maximum row we put a value
        gbc.gridy = gridyMax;
    }

    if (lastRowButton != null) {
        // add a configuration button on the last row
        gbc.insets = new java.awt.Insets(0, 10, 0, 10);
        gbc.gridx = 0;
        gbc.gridy++;
        add(lastRowButton, gbc);
    }

    // add an empty cell that takes all remaining space to
    // align the visible cells at the top-left corner
    gbc.gridy++;
    gbc.gridx = Math.min(text.length(), maxTextLength) + 1;
    gbc.gridwidth = GridBagConstraints.REMAINDER;
    gbc.gridheight = GridBagConstraints.REMAINDER;
    gbc.weightx = 1;
    gbc.weighty = 1;
    add(new JLabel(""), gbc);

    validate();
    updateUI();
}

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

private void initComponents() {

    this.setModalityType(Dialog.ModalityType.DOCUMENT_MODAL);

    int gridy = 0;

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

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

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

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

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

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

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

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

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

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

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

    ActionListener usernamePasswordListener = new ActionListener() {

        public void actionPerformed(ActionEvent e) {

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

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

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

    /////SAML

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

    ActionListener getCookieListener = new ActionListener() {

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

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

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

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

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

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

    //END SAML

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

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

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

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

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

    addDivider(mainPanel, SwingConstants.BOTTOM, true);

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

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

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

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