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.usfirst.frc.team2084.neuralnetwork.HeadingNeuralNetworkTrainer.java
public HeadingNeuralNetworkTrainer() { outputGraphNetworkSeries = new XYSeries("Network Prediction"); outputGraphDataSeries = new XYSeries("Error"); final XYSeriesCollection data = new XYSeriesCollection(); data.addSeries(outputGraphDataSeries); data.addSeries(outputGraphNetworkSeries); outputGraph = ChartFactory.createXYLineChart("Error vs. Output", "Time", "Error", data, PlotOrientation.VERTICAL, true, true, false); NumberAxis xAxis = new NumberAxis(); xAxis.setRange(new Range(-Math.PI, Math.PI)); xAxis.setAutoRange(false);/*from w w w . j a v a 2 s .c o m*/ NumberAxis yAxis = new NumberAxis(); yAxis.setRange(new Range(-1, 1)); XYPlot plot = (XYPlot) outputGraph.getPlot(); plot.setDomainAxis(xAxis); plot.setRangeAxis(yAxis); network = new Network(new int[] { 1, 5, 1 }, eta, momentum, new TransferFunction.HyperbolicTangent()); try { SwingUtilities.invokeAndWait(() -> { frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); final Container content = frame.getContentPane(); content.setLayout(new BorderLayout()); outputGraphPanel = new ChartPanel(outputGraph); outputGraphPanel.setDomainZoomable(false); outputGraphPanel.setRangeZoomable(false); graphPanel.add(outputGraphPanel); graphPanel.setLayout(new GridLayout(1, 1)); content.add(graphPanel, BorderLayout.CENTER); { JLabel etaLabel = new JLabel("Eta:"); etaLabel.setLabelFor(etaField); etaField.setText(Double.toString(network.getEta())); etaField.setColumns(5); etaField.addPropertyChangeListener("value", (evt) -> eta = ((Number) evt.getNewValue()).doubleValue()); controlPanel.add(etaLabel); controlPanel.add(etaField); JLabel momentumLabel = new JLabel("Momentum:"); momentumLabel.setLabelFor(etaField); momentumField.setText(Double.toString(network.getMomentum())); momentumField.setColumns(5); momentumField.addPropertyChangeListener("value", (evt) -> momentum = ((Number) evt.getNewValue()).doubleValue()); controlPanel.add(momentumLabel); controlPanel.add(momentumField); JLabel iterationsLabel = new JLabel("Iterations:"); iterationsLabel.setLabelFor(iterationsField); iterationsField.setText(Integer.toString(iterations)); iterationsField.setColumns(10); iterationsField.addPropertyChangeListener("value", (evt) -> iterations = ((Number) evt.getNewValue()).intValue()); controlPanel.add(iterationsLabel); controlPanel.add(iterationsField); } chooseDataButton.addActionListener((e) -> { if (dataDirectoryChooser.showOpenDialog(frame) == JFileChooser.APPROVE_OPTION) { dataDirectory = dataDirectoryChooser.getSelectedFile(); displayData(); } }); controlPanel.add(chooseDataButton); trainButton.addActionListener((e) -> trainNetwork()); controlPanel.add(trainButton); saveButton.addActionListener((e) -> { saveNetwork(); }); controlPanel.add(saveButton); content.add(controlPanel, BorderLayout.SOUTH); dataDirectoryChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.pack(); frame.setVisible(true); }); } catch (InvocationTargetException | InterruptedException e) { e.printStackTrace(); } }
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;//from w w w . j a v a2s . co m 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; }
From source file:de.tbuchloh.kiskis.gui.AbstractAccountDetailView.java
protected void addRow(final JPanel panel, final String labelText, final Component comp) { final JLabel label = new JLabel(labelText, SwingConstants.TRAILING); panel.add(label);//from w w w. ja v a 2 s.c o m label.setLabelFor(comp); panel.add(comp); }
From source file:de.tbuchloh.kiskis.gui.SecuredElementView.java
private Component createMainTab() { final JPanel textFields = new JPanel(new SpringLayout()); textFields.setBorder(LnFHelper.createDefaultBorder()); final JLabel nameLabel = LnFHelper.createLabel(M.getString("name_label")); //$NON-NLS-1$ nameLabel.setVerticalAlignment(SwingConstants.TOP); nameLabel.setLabelFor(_name); textFields.add(nameLabel);//ww w . j a v a 2 s. c om textFields.add(_name); final JLabel pwdLabel = LnFHelper.createLabel(M.getString("password_label")); //$NON-NLS-1$ pwdLabel.setVerticalAlignment(SwingConstants.TOP); pwdLabel.setLabelFor(_pwdField); textFields.add(pwdLabel); textFields.add(_pwdField); final JPanel datePanel = new JPanel(); final GridBagBuilder builder = new GridBagBuilder(datePanel); builder.setAlignment(GridBagConstraints.NORTHWEST); builder.add(_dateField); builder.add(_neverBox); builder.setFill(GridBagConstraints.NONE); builder.setAlignment(GridBagConstraints.EAST); builder.addLast(_historyLink); builder.setFill(GridBagConstraints.BOTH); builder.setAlignment(GridBagConstraints.NORTHWEST); final JLabel expiresLabel = LnFHelper.createLabel(M.getString("expires_label")); //$NON-NLS-1$ expiresLabel.setVerticalAlignment(SwingConstants.TOP); expiresLabel.setLabelFor(datePanel); textFields.add(expiresLabel); textFields.add(datePanel); SpringUtilities.makeCompactGrid(textFields, 3, 2, 5, 5, 5, 5); return textFields; }
From source file:DefaultsDisplay.java
protected JComponent createLookAndFeelControl() { JPanel panel = new JPanel(); JLabel label = new JLabel("Current Look and Feel"); lookAndFeelComboBox = new JComboBox(); label.setLabelFor(lookAndFeelComboBox); panel.add(label);/*from w w w . j av a 2 s .c o m*/ panel.add(lookAndFeelComboBox); // Look for toolkit look and feels first UIManager.LookAndFeelInfo lookAndFeelInfos[] = UIManager.getInstalledLookAndFeels(); lookAndFeelsMap = new HashMap<String, String>(); for (UIManager.LookAndFeelInfo info : lookAndFeelInfos) { String name = info.getName(); // workaround for problem where Info and name property don't match on OS X if (name.equals("Mac OS X")) { name = OSXLookAndFeelName; } // workaround for bug where Nimbus classname is incorrect lookAndFeelsMap.put(name, name.equals("Nimbus") ? "com.sun.java.swing.plaf.nimbus.NimbusLookAndFeel" : info.getClassName()); lookAndFeelComboBox.addItem(name); } lookAndFeelComboBox.setSelectedItem(UIManager.getLookAndFeel().getName()); lookAndFeelComboBox.addActionListener(new ChangeLookAndFeelAction()); return panel; }
From source file:org.gridchem.client.gui.charts.UsageChart.java
private JPanel createSelectionBar() { chartTypeListModel = new CyclingSpinnerListModel(ChartType.values()); chartTypeSpinner = new JSpinner(chartTypeListModel); JFormattedTextField ftf = ((JSpinner.DefaultEditor) chartTypeSpinner.getEditor()).getTextField(); ftf.setColumns(6); //specify more width than we need ftf.setHorizontalAlignment(JTextField.CENTER); ftf.setEditable(false);//from www .j a v a 2s . com JLabel spinnerLabel = new JLabel("Chart Type"); spinnerLabel.setLabelFor(chartTypeSpinner); JPanel buttonPanel = new JPanel(); buttonPanel.add(spinnerLabel, BorderLayout.CENTER); buttonPanel.add(chartTypeSpinner, BorderLayout.LINE_END); return buttonPanel; }
From source file:com.eviware.soapui.support.components.SimpleForm.java
private <T extends JComponent> T append(String name, JComponent label, T component, String alignments, int column, int columnSpan) { int spaceRowIndex = -1; if (rowSpacing > 0 && appended) { addSpace(rowSpacing);/* w w w .j a v a 2 s. c o m*/ spaceRowIndex = layout.getRowCount(); } layout.appendRow(rowSpec); int row = layout.getRowCount(); if (label != null) { panel.add(label, cc.xy(DEFAULT_LABEL_COLUMN, row)); component.addComponentListener(new LabelHider(label, spaceRowIndex)); component.addPropertyChangeListener(ENABLED_PROPERTY_NAME, new LabelEnabler(label)); if (label instanceof JLabel) { JLabel jl = ((JLabel) label); jl.setLabelFor(component); String text = jl.getText(); int ix = text.indexOf('&'); if (ix >= 0) { jl.setText(text.substring(0, ix) + text.substring(ix + 1)); jl.setDisplayedMnemonicIndex(ix); jl.setDisplayedMnemonic(text.charAt(ix + 1)); } if (component.getAccessibleContext() != null) { component.getAccessibleContext().setAccessibleName(text); } } } else { component.addComponentListener(new LabelHider(null, spaceRowIndex)); } addComponentToRow(name, component, alignments, column, row, columnSpan); return component; }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java
private JPanel getPortPanel() { port = new JTextField(4); JLabel label = new JLabel(UPMPConstant.upmp_server_port); // $NON-NLS-1$ label.setLabelFor(port); JPanel panel = new JPanel(new BorderLayout(5, 0)); panel.add(label, BorderLayout.WEST); panel.add(port, BorderLayout.CENTER); return panel; }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java
private JPanel getProxyPortPanel() { proxyPort = new JTextField(4); JLabel label = new JLabel(UPMPConstant.upmp_server_port); // $NON-NLS-1$ label.setLabelFor(proxyPort); JPanel panel = new JPanel(new BorderLayout(5, 0)); panel.add(label, BorderLayout.WEST); panel.add(proxyPort, BorderLayout.CENTER); return panel; }
From source file:com.unionpay.upmp.jmeterplugin.gui.UPMPUrlConfigGui.java
private JPanel getProxyHostPanel() { proxyHost = new JTextField(20); JLabel label = new JLabel(UPMPConstant.upmp_proxy_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; }