Example usage for javax.swing JLabel setLabelFor

List of usage examples for javax.swing JLabel setLabelFor

Introduction

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

Prototype

@BeanProperty(description = "The component this is labelling.")
public void setLabelFor(Component c) 

Source Link

Document

Set the component this is labelling.

Usage

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

private JPanel getDomainPanel() {
    domain = new JTextField(20);

    JLabel label = new JLabel(UPMPConstant.upmp_server_domain); // $NON-NLS-1$
    label.setLabelFor(domain);

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(domain, BorderLayout.CENTER);
    return panel;
}

From source file:org.onesun.sdi.swing.app.views.DataServicesView.java

private void addControlsToPanel() {
    dataTable.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
    dataTable.setAutoscrolls(true);// ww  w.j a v a  2 s.  c  o  m

    JPanel panel = null;

    panel = new JPanel(new SpringLayout());
    panel.add(copyDataButton);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    panel.add(containerPanel);
    SpringLayoutUtils.makeCompactGrid(panel, 1, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.CENTER));
    panel.add(executeButton);
    panel.add(computeMetricsButton);
    this.add(panel);

    panel = new JPanel(new SpringLayout());
    JLabel label = new JLabel("Enriched Data", JLabel.LEADING);
    label.setPreferredSize(new Dimension(150, 24));
    scrollPane.setPreferredSize(new Dimension(250, 900));

    scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED);
    scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED);

    panel.add(label);
    label.setLabelFor(scrollPane);
    panel.add(scrollPane);
    SpringLayoutUtils.makeCompactGrid(panel, 2, 1, 5, 5, 5, 5);
    this.add(panel);

    panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    panel.add(rowCountLabel);
    this.add(panel);
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

private JPanel getProxyUserPanel() {
    proxyUser = new JTextField(5);

    JLabel label = new JLabel(JMeterUtils.getResString("username")); // $NON-NLS-1$
    label.setLabelFor(proxyUser);

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(proxyUser, BorderLayout.CENTER);
    return panel;
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

private JPanel getProxyPassPanel() {
    proxyPass = new JPasswordField(5);

    JLabel label = new JLabel(JMeterUtils.getResString("password")); // $NON-NLS-1$
    label.setLabelFor(proxyPass);

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(proxyPass, BorderLayout.CENTER);
    return panel;
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

private JPanel getConnectTimeOutPanel() {
    connectTimeOut = new JTextField(4);

    JLabel label = new JLabel(UPMPConstant.upmp_server_timeout_connect); // $NON-NLS-1$
    label.setLabelFor(connectTimeOut);

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(connectTimeOut, BorderLayout.CENTER);

    return panel;
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

private JPanel getResponseTimeOutPanel() {
    responseTimeOut = new JTextField(4);

    JLabel label = new JLabel(UPMPConstant.upmp_server_timeout_response); // $NON-NLS-1$
    label.setLabelFor(responseTimeOut);

    JPanel panel = new JPanel(new BorderLayout(5, 0));
    panel.add(label, BorderLayout.WEST);
    panel.add(responseTimeOut, BorderLayout.CENTER);

    return panel;
}

From source file:components.TableFilterDemo.java

public TableFilterDemo() {
    super();//from  w  ww .java 2 s  .c o m
    setLayout(new BoxLayout(this, BoxLayout.Y_AXIS));

    //Create a table with a sorter.
    MyTableModel model = new MyTableModel();
    sorter = new TableRowSorter<MyTableModel>(model);
    table = new JTable(model);
    table.setRowSorter(sorter);
    table.setPreferredScrollableViewportSize(new Dimension(500, 70));
    table.setFillsViewportHeight(true);

    //For the purposes of this example, better to have a single
    //selection.
    table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);

    //When selection changes, provide user with row numbers for
    //both view and model.
    table.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
        public void valueChanged(ListSelectionEvent event) {
            int viewRow = table.getSelectedRow();
            if (viewRow < 0) {
                //Selection got filtered away.
                statusText.setText("");
            } else {
                int modelRow = table.convertRowIndexToModel(viewRow);
                statusText.setText(String.format("Selected Row in view: %d. " + "Selected Row in model: %d.",
                        viewRow, modelRow));
            }
        }
    });

    //Create the scroll pane and add the table to it.
    JScrollPane scrollPane = new JScrollPane(table);

    //Add the scroll pane to this panel.
    add(scrollPane);

    //Create a separate form for filterText and statusText
    JPanel form = new JPanel(new SpringLayout());
    JLabel l1 = new JLabel("Filter Text:", SwingConstants.TRAILING);
    form.add(l1);
    filterText = new JTextField();
    //Whenever filterText changes, invoke newFilter.
    filterText.getDocument().addDocumentListener(new DocumentListener() {
        public void changedUpdate(DocumentEvent e) {
            newFilter();
        }

        public void insertUpdate(DocumentEvent e) {
            newFilter();
        }

        public void removeUpdate(DocumentEvent e) {
            newFilter();
        }
    });
    l1.setLabelFor(filterText);
    form.add(filterText);
    JLabel l2 = new JLabel("Status:", SwingConstants.TRAILING);
    form.add(l2);
    statusText = new JTextField();
    l2.setLabelFor(statusText);
    form.add(statusText);
    SpringUtilities.makeCompactGrid(form, 2, 2, 6, 6, 6, 6);
    add(form);
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

/**
 * This method defines the Panel for the HTTP path, 'Follow Redirects'
 * 'Use KeepAlive', and 'Use multipart for HTTP POST' elements.
 *
 * @return JPanel The Panel for the path, 'Follow Redirects' and 'Use
 *         KeepAlive' elements.//from   w w  w  . j a va2  s .c om
 */
protected Component getPathPanel() {
    path = new JTextField(15);

    JLabel label = new JLabel(JMeterUtils.getResString("path")); //$NON-NLS-1$
    label.setLabelFor(path);

    if (notConfigOnly) {
        followRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects")); // $NON-NLS-1$
        followRedirects.setSelected(true);
        followRedirects.addChangeListener(this);

        autoRedirects = new JCheckBox(JMeterUtils.getResString("follow_redirects_auto")); //$NON-NLS-1$
        autoRedirects.addChangeListener(this);
        autoRedirects.setSelected(false);// Default changed in 2.3 and again in 2.4

        useKeepAlive = new JCheckBox(JMeterUtils.getResString("use_keepalive")); // $NON-NLS-1$
        useKeepAlive.setSelected(true);

        useMultipartForPost = new JCheckBox(JMeterUtils.getResString("use_multipart_for_http_post")); // $NON-NLS-1$
        useMultipartForPost.setSelected(false);

        useBrowserCompatibleMultipartMode = new JCheckBox(
                JMeterUtils.getResString("use_multipart_mode_browser")); // $NON-NLS-1$
        useBrowserCompatibleMultipartMode
                .setSelected(UPMPSamplerBase.BROWSER_COMPATIBLE_MULTIPART_MODE_DEFAULT);

    }

    JPanel pathPanel = new JPanel(new BorderLayout(5, 0));
    pathPanel.add(label, BorderLayout.WEST);
    pathPanel.add(path, BorderLayout.CENTER);
    pathPanel.setMinimumSize(pathPanel.getPreferredSize());

    JPanel panel = new JPanel();
    panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
    panel.add(pathPanel);
    if (notConfigOnly) {
        JPanel optionPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
        optionPanel.add(autoRedirects);
        optionPanel.add(followRedirects);
        optionPanel.add(useKeepAlive);
        optionPanel.add(useMultipartForPost);
        optionPanel.add(useBrowserCompatibleMultipartMode);
        optionPanel.setMinimumSize(optionPanel.getPreferredSize());
        panel.add(optionPanel);
    }

    return panel;
}

From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java

protected JPanel getProtocolAndMethodPanel() {

    // Implementation

    if (showImplementation) {
        httpImplementation = new JLabeledChoice(UPMPConstant.upmp_implementation, // $NON-NLS-1$
                UPMPSamplerFactory.getImplementations());
        httpImplementation.addValue("");
    }//from   w w w .  ja va  2s .  c o  m
    // PROTOCOL
    protocol = new JTextField(4);
    JLabel protocolLabel = new JLabel(JMeterUtils.getResString("protocol")); // $NON-NLS-1$
    protocolLabel.setLabelFor(protocol);

    // CONTENT_ENCODING
    contentEncoding = new JTextField(10);
    JLabel contentEncodingLabel = new JLabel(JMeterUtils.getResString("content_encoding")); // $NON-NLS-1$
    contentEncodingLabel.setLabelFor(contentEncoding);

    if (notConfigOnly) {
        method = new JLabeledChoice(JMeterUtils.getResString("method"), // $NON-NLS-1$
                UPMPSamplerBase.getValidMethodsAsArray());
    }

    JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));

    if (showImplementation) {
        panel.add(httpImplementation);
    }
    panel.add(protocolLabel);
    panel.add(protocol);
    panel.add(Box.createHorizontalStrut(5));

    if (notConfigOnly) {
        panel.add(method);
    }
    panel.setMinimumSize(panel.getPreferredSize());
    panel.add(Box.createHorizontalStrut(5));

    panel.add(contentEncodingLabel);
    panel.add(contentEncoding);
    panel.setMinimumSize(panel.getPreferredSize());
    return panel;
}

From source file:adams.gui.tools.TelnetPanel.java

/**
 * For initializing the GUI./*from w  ww.j  a va 2s . c o  m*/
 */
@Override
protected void initGUI() {
    JPanel topPanel;
    JPanel bottomPanel;
    JLabel label;

    super.initGUI();

    setLayout(new BorderLayout());

    // connection
    topPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(topPanel, BorderLayout.NORTH);

    m_TextRemote = new BaseTextField(20);
    label = new JLabel("Remote");
    label.setDisplayedMnemonic('R');
    label.setLabelFor(m_TextRemote);
    topPanel.add(label);
    topPanel.add(m_TextRemote);

    m_PortModel = new SpinnerNumberModel();
    m_PortModel.setMinimum(1);
    m_PortModel.setMaximum(65536);
    m_PortModel.setStepSize(1);
    m_PortModel.setValue(23);
    m_SpinnerPort = new JSpinner(m_PortModel);
    label = new JLabel("Port");
    label.setDisplayedMnemonic('P');
    label.setLabelFor(m_SpinnerPort);
    topPanel.add(label);
    topPanel.add(m_SpinnerPort);

    m_ButtonConnection = new BaseButton();
    m_ButtonConnection.setMnemonic('n');
    m_ButtonConnection.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            handleConnectionEvent();
        }
    });
    topPanel.add(m_ButtonConnection);

    // output
    m_ButtonClear = new BaseButton("Clear", GUIHelper.getIcon("new.gif"));
    m_ButtonClear.setMnemonic('l');
    m_ButtonClear.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            m_TextOutput.setText("");
        }
    });
    m_ButtonCopy = new BaseButton("Copy", GUIHelper.getIcon("copy.gif"));
    m_ButtonCopy.setMnemonic('C');
    m_ButtonCopy.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            if (m_TextOutput.getSelectedText().length() > 0)
                ClipboardHelper.copyToClipboard(m_TextOutput.getSelectedText());
            else if (m_TextOutput.getText().length() > 0)
                ClipboardHelper.copyToClipboard(m_TextOutput.getText());
        }
    });
    m_TextOutput = new BaseTextAreaWithButtons(10, 40);
    m_TextOutput.setTextFont(Fonts.getMonospacedFont());
    m_TextOutput.addToButtonsPanel(m_ButtonClear);
    m_TextOutput.addToButtonsPanel(m_ButtonCopy);
    add(m_TextOutput, BorderLayout.CENTER);

    // commands
    bottomPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    add(bottomPanel, BorderLayout.SOUTH);

    m_TextCommand = new BaseTextField(40);
    m_TextCommand.setFont(Fonts.getMonospacedFont());
    m_TextCommand.addKeyListener(new KeyListener() {
        @Override
        public void keyTyped(KeyEvent e) {
        }

        @Override
        public void keyReleased(KeyEvent e) {
        }

        @Override
        public void keyPressed(KeyEvent e) {
            switch (e.getKeyCode()) {
            case KeyEvent.VK_ENTER:
                e.consume();
                execCommand();
                break;
            case KeyEvent.VK_UP:
                e.consume();
                previousCommand();
                break;
            case KeyEvent.VK_DOWN:
                e.consume();
                nextCommand();
                break;
            }
        }
    });
    label = new JLabel("Command");
    label.setDisplayedMnemonic('m');
    label.setLabelFor(m_TextCommand);
    bottomPanel.add(label);
    bottomPanel.add(m_TextCommand);

    m_ButtonCommand = new BaseButton(GUIHelper.getIcon("run.gif"));
    m_ButtonCommand.addActionListener(new ActionListener() {
        @Override
        public void actionPerformed(ActionEvent e) {
            execCommand();
        }
    });
    bottomPanel.add(m_ButtonCommand);
}