List of usage examples for javax.swing JLabel setLabelFor
@BeanProperty(description = "The component this is labelling.") public void setLabelFor(Component c)
From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java
private JPanel getClassifierPanel() { type = new JTextField(20); JLabel label = new JLabel("Type"); // $NON-NLS-1$ label.setLabelFor(type); JPanel panel = new JPanel(new BorderLayout(5, 0)); panel.add(label, BorderLayout.WEST); panel.add(type, BorderLayout.CENTER); return panel; }
From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java
private JPanel getProxyHostPanel() { proxyHost = new JTextField(20); JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$ label.setLabelFor(proxyHost); JPanel panel = new JPanel(new BorderLayout(5, 0)); panel.add(label, BorderLayout.WEST); panel.add(proxyHost, BorderLayout.CENTER); return panel; }
From source file:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.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 ww w . j ava 2 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(HTTPSamplerBase.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:org.apache.jmeter.protocol.http.config.gui.UrlConfigGuiClassifier.java
protected JPanel getProtocolAndMethodPanel() { // Implementation if (showImplementation) { httpImplementation = new JLabeledChoice(JMeterUtils.getResString("http_implementation"), // $NON-NLS-1$ HTTPSamplerFactory.getImplementations()); httpImplementation.addValue(""); }/*from w w w . j av a 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$ HTTPSamplerBase.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:org.apache.jmeter.protocol.http.control.gui.WebServiceSamplerGui.java
private JPanel getProxyHostPanel() { proxyHost = new JTextField(12); JLabel label = new JLabel(JMeterUtils.getResString("web_server_domain")); // $NON-NLS-1$ label.setLabelFor(proxyHost); JPanel panel = new JPanel(new BorderLayout(5, 0)); panel.add(label, BorderLayout.WEST); panel.add(proxyHost, BorderLayout.CENTER); return panel; }
From source file:org.apache.jmeter.protocol.java.config.gui.JavaConfigGui.java
/** * Create a panel with GUI components allowing the user to select a test * class./*w w w. j a va2 s.c o m*/ * * @return a panel containing the relevant components */ private JPanel createClassnamePanel() { List<String> possibleClasses = new ArrayList<>(); try { // Find all the classes which implement the JavaSamplerClient // interface. possibleClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { JavaSamplerClient.class }); // Remove the JavaConfig class from the list since it only // implements the interface for error conditions. possibleClasses.remove(JavaSampler.class.getName() + "$ErrorSamplerClient"); } catch (Exception e) { log.debug("Exception getting interfaces.", e); } JLabel label = new JLabel(JMeterUtils.getResString("protocol_java_classname")); // $NON-NLS-1$ classnameCombo = new JComboBox<>(possibleClasses.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); classnameCombo.addActionListener(this); classnameCombo.setEditable(false); label.setLabelFor(classnameCombo); HorizontalPanel panel = new HorizontalPanel(); panel.add(label); panel.add(classnameCombo); return panel; }
From source file:org.apache.jmeter.testbeans.gui.GenericTestBeanCustomizer.java
/** * Initialize the GUI.// w ww .j av a 2s. co m */ private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) setLayout(new GridBagLayout()); GridBagConstraints cl = new GridBagConstraints(); // for labels cl.gridx = 0; cl.anchor = GridBagConstraints.EAST; cl.insets = new Insets(0, 1, 0, 1); GridBagConstraints ce = new GridBagConstraints(); // for editors ce.fill = GridBagConstraints.BOTH; ce.gridx = 1; ce.weightx = 1.0; ce.insets = new Insets(0, 1, 0, 1); GridBagConstraints cp = new GridBagConstraints(); // for panels cp.fill = GridBagConstraints.BOTH; cp.gridx = 1; cp.gridy = GridBagConstraints.RELATIVE; cp.gridwidth = 2; cp.weightx = 1.0; JPanel currentPanel = this; String currentGroup = DEFAULT_GROUP; int y = 0; for (int i = 0; i < editors.length; i++) { if (editors[i] == null) { continue; } if (log.isDebugEnabled()) { log.debug("Laying property " + descriptors[i].getName()); } String g = group(descriptors[i]); if (!currentGroup.equals(g)) { if (currentPanel != this) { add(currentPanel, cp); } currentGroup = g; currentPanel = new JPanel(new GridBagLayout()); currentPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), groupDisplayName(g))); cp.weighty = 0.0; y = 0; } Component customEditor = editors[i].getCustomEditor(); boolean multiLineEditor = false; if (customEditor.getPreferredSize().height > 50 || customEditor instanceof JScrollPane || descriptors[i].getValue(MULTILINE) != null) { // TODO: the above works in the current situation, but it's // just a hack. How to get each editor to report whether it // wants to grow bigger? Whether the property label should // be at the left or at the top of the editor? ...? multiLineEditor = true; } JLabel label = createLabel(descriptors[i]); label.setLabelFor(customEditor); cl.gridy = y; cl.gridwidth = multiLineEditor ? 2 : 1; cl.anchor = multiLineEditor ? GridBagConstraints.CENTER : GridBagConstraints.EAST; currentPanel.add(label, cl); ce.gridx = multiLineEditor ? 0 : 1; ce.gridy = multiLineEditor ? ++y : y; ce.gridwidth = multiLineEditor ? 2 : 1; ce.weighty = multiLineEditor ? 1.0 : 0.0; cp.weighty += ce.weighty; currentPanel.add(customEditor, ce); y++; } if (currentPanel != this) { add(currentPanel, cp); } // Add a 0-sized invisible component that will take all the vertical // space that nobody wants: cp.weighty = 0.0001; add(Box.createHorizontalStrut(0), cp); }
From source file:org.apache.jmeter.visualizers.backend.BackendListenerGui.java
/** * Create a panel with GUI components allowing the user to select a test * class./*from www .j a v a 2 s . c o m*/ * * @return a panel containing the relevant components */ private JPanel createClassnamePanel() { List<String> possibleClasses = new ArrayList<>(); try { // Find all the classes which implement the BackendListenerClient // interface. possibleClasses = ClassFinder.findClassesThatExtend(JMeterUtils.getSearchPaths(), new Class[] { BackendListenerClient.class }); // Remove the BackendListener class from the list since it only // implements the interface for error conditions. possibleClasses.remove(BackendListener.class.getName() + "$ErrorBackendListenerClient"); } catch (Exception e) { LOGGER.debug("Exception getting interfaces.", e); } JLabel label = new JLabel(JMeterUtils.getResString("backend_listener_classname")); // $NON-NLS-1$ classnameCombo = new JComboBox<>(possibleClasses.toArray(ArrayUtils.EMPTY_STRING_ARRAY)); classnameCombo.addActionListener(this); classnameCombo.setEditable(false); label.setLabelFor(classnameCombo); HorizontalPanel classNamePanel = new HorizontalPanel(); classNamePanel.add(label); classNamePanel.add(classnameCombo); queueSize = new JTextField(BackendListener.DEFAULT_QUEUE_SIZE, 5); queueSize.setName("Queue Size"); //$NON-NLS-1$ JLabel queueSizeLabel = new JLabel(JMeterUtils.getResString("backend_listener_queue_size")); // $NON-NLS-1$ queueSizeLabel.setLabelFor(queueSize); HorizontalPanel queueSizePanel = new HorizontalPanel(); queueSizePanel.add(queueSizeLabel, BorderLayout.WEST); queueSizePanel.add(queueSize); JPanel panel = new JPanel(new BorderLayout(0, 5)); panel.add(classNamePanel, BorderLayout.NORTH); panel.add(queueSizePanel, BorderLayout.CENTER); return panel; }
From source file:org.bitbucket.mlopatkin.android.logviewer.ConfigurationDialog.java
private ConfigurationDialog(Frame owner) { super(owner); setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); setModalityType(ModalityType.APPLICATION_MODAL); setTitle("Configuration"); setBounds(100, 100, 400, 122);//from w ww. j a va2 s.c o m getContentPane().setLayout(new BorderLayout()); contentPanel.setBorder(new EmptyBorder(5, 5, 5, 5)); getContentPane().add(contentPanel, BorderLayout.CENTER); JLabel lblAdbExecutableLocation = new JLabel("ADB executable location"); textAdbExecutable = new JTextField(Configuration.adb.executable()); lblAdbExecutableLocation.setLabelFor(textAdbExecutable); textAdbExecutable.setColumns(10); JButton btBrowseAdb = new JButton("..."); btBrowseAdb.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JFileChooser fileChooser = new JFileChooser(); int result = fileChooser.showOpenDialog(ConfigurationDialog.this); if (result == JFileChooser.APPROVE_OPTION) { textAdbExecutable.setText(fileChooser.getSelectedFile().getAbsolutePath()); } } }); GroupLayout gl_contentPanel = new GroupLayout(contentPanel); gl_contentPanel.setHorizontalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPanel.createSequentialGroup().addComponent(lblAdbExecutableLocation) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(textAdbExecutable, GroupLayout.DEFAULT_SIZE, 486, Short.MAX_VALUE) .addPreferredGap(ComponentPlacement.RELATED) .addComponent(btBrowseAdb, GroupLayout.PREFERRED_SIZE, 33, GroupLayout.PREFERRED_SIZE))); gl_contentPanel.setVerticalGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) .addGroup(gl_contentPanel.createSequentialGroup() .addGroup(gl_contentPanel.createParallelGroup(Alignment.LEADING) .addComponent(lblAdbExecutableLocation) .addGroup(gl_contentPanel.createParallelGroup(Alignment.BASELINE) .addComponent(textAdbExecutable, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE) .addComponent(btBrowseAdb))) .addContainerGap(375, Short.MAX_VALUE))); contentPanel.setLayout(gl_contentPanel); { JPanel buttonPane = new JPanel(); buttonPane.setLayout(new FlowLayout(FlowLayout.RIGHT)); getContentPane().add(buttonPane, BorderLayout.SOUTH); { JButton okButton = new JButton(acOk); buttonPane.add(okButton); getRootPane().setDefaultButton(okButton); } { JButton cancelButton = new JButton(acCancel); buttonPane.add(cancelButton); } } }
From source file:org.codinjutsu.tools.jenkins.view.BuildParamDialog.java
private void addParameterInputs() { contentPanel.setLayout(new SpringLayout()); List<JobParameter> parameters = job.getParameters(); for (JobParameter jobParameter : parameters) { JComponent inputField = createInputField(jobParameter); String name = jobParameter.getName(); inputField.setName(name);//from w ww.j av a2 s . c o m JLabel label = new JLabel(); label.setHorizontalAlignment(JLabel.TRAILING); label.setLabelFor(inputField); if (StringUtils.isEmpty(name)) { name = MISSING_NAME_LABEL; label.setIcon(ERROR_ICON); hasError = true; } label.setText(name + ":"); contentPanel.add(label); contentPanel.add(inputField); inputFieldByParameterMap.put(jobParameter, inputField); } SpringUtilities.makeCompactGrid(contentPanel, parameters.size(), 2, 6, 6, //initX, initY 6, 6); //xPad, yPad if (hasError) { buttonOK.setEnabled(false); } }