javax.swing.JLabel.setLabelFor()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(10.9k)|赞(0)|评价(0)|浏览(202)

本文整理了Java中javax.swing.JLabel.setLabelFor()方法的一些代码示例,展示了JLabel.setLabelFor()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JLabel.setLabelFor()方法的具体详情如下:
包路径:javax.swing.JLabel
类名称:JLabel
方法名:setLabelFor

JLabel.setLabelFor介绍

暂无

代码示例

代码示例来源:origin: skylot/jadx

public void addRow(String label, String tooltip, JComponent comp) {
  c.gridy = row++;
  JLabel jLabel = new JLabel(label);
  jLabel.setLabelFor(comp);
  jLabel.setHorizontalAlignment(SwingConstants.LEFT);
  c.gridx = 0;
  c.gridwidth = 1;
  c.anchor = GridBagConstraints.LINE_START;
  c.weightx = 0.8;
  c.fill = GridBagConstraints.NONE;
  add(jLabel, c);
  c.gridx = 1;
  c.gridwidth = GridBagConstraints.REMAINDER;
  c.anchor = GridBagConstraints.CENTER;
  c.weightx = 0.2;
  c.fill = GridBagConstraints.HORIZONTAL;
  if (tooltip != null) {
    jLabel.setToolTipText(tooltip);
    comp.setToolTipText(tooltip);
  }
  add(comp, c);
  comp.addPropertyChangeListener("enabled", evt -> jLabel.setEnabled((boolean) evt.getNewValue()));
}

代码示例来源:origin: deathmarine/Luyten

protected JPanel getFontFamilyPanel() {
  if (fontNamePanel == null) {
    fontNamePanel = new JPanel();
    fontNamePanel.setLayout(new BorderLayout());
    fontNamePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    fontNamePanel.setPreferredSize(new Dimension(180, 130));
    JScrollPane scrollPane = new JScrollPane(getFontFamilyList());
    scrollPane.getVerticalScrollBar().setFocusable(false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(getFontFamilyTextField(), BorderLayout.NORTH);
    p.add(scrollPane, BorderLayout.CENTER);
    JLabel label = new JLabel(("Font Name"));
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setHorizontalTextPosition(JLabel.LEFT);
    label.setLabelFor(getFontFamilyTextField());
    label.setDisplayedMnemonic('F');
    fontNamePanel.add(label, BorderLayout.NORTH);
    fontNamePanel.add(p, BorderLayout.CENTER);
  }
  return fontNamePanel;
}

代码示例来源:origin: stackoverflow.com

String[] labels = {"Name: ", "Fax: ", "Email: ", "Address: "};
int numPairs = labels.length;

//Create and populate the panel.
JPanel p = new JPanel(new SpringLayout());
for (int i = 0; i < numPairs; i++) {
  JLabel l = new JLabel(labels[i], JLabel.TRAILING);
  p.add(l);
  JTextField textField = new JTextField(10);
  l.setLabelFor(textField);
  p.add(textField);
}

//Lay out the panel.
SpringUtilities.makeCompactGrid(p,
                numPairs, 2, //rows, cols
                6, 6,        //initX, initY
                6, 6);       //xPad, yPad

代码示例来源:origin: magefree/mage

jLabel1 = new javax.swing.JLabel();
cbPlayerType = new javax.swing.JComboBox();
lblPlayerNum = new javax.swing.JLabel();
pnlPlayerName = new javax.swing.JPanel();
txtPlayerName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
spnLevel = new javax.swing.JSpinner();
jLabel1.setLabelFor(cbPlayerType);
jLabel1.setText("Type:");

代码示例来源:origin: org.netbeans.api/org-openide-awt

final JLabel lbl;
if (popupMenu != null) {
  lbl = new JLabel(org.openide.util.ImageUtilities.loadImageIcon(ICON_FIND_WITH_MENU, false));
  lbl.addMouseListener(new MouseAdapter() {
    @Override
  lbl = new JLabel(org.openide.util.ImageUtilities.loadImageIcon(ICON_FIND, false));
  searchPanel.add(lbl);
searchPanel.add(searchTextField);
searchPanel.setBackground(component.getBackground());
lbl.setLabelFor(searchTextField);
searchTextField.setColumns(10);
searchTextField.setMaximumSize(searchTextField.getPreferredSize());

代码示例来源:origin: org.appdapter/org.appdapter.lib.gui

public static JPanel createTitledPanel(JLabel label, char mnemonic, JComponent component) {
  JPanel panel = new JPanel(new BorderLayout(2, 2));
  panel.add(label, BorderLayout.BEFORE_FIRST_LINE);
  label.setDisplayedMnemonic(mnemonic);
  if (component instanceof JScrollPane) {
    label.setLabelFor(((JScrollPane) component).getViewport().getView());
  } else {
    label.setLabelFor(component);
  }
  panel.add(component, BorderLayout.CENTER);
  return panel;
}

代码示例来源:origin: deathmarine/Luyten

protected JPanel getFontStylePanel() {
  if (fontStylePanel == null) {
    fontStylePanel = new JPanel();
    fontStylePanel.setLayout(new BorderLayout());
    fontStylePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    fontStylePanel.setPreferredSize(new Dimension(140, 130));
    JScrollPane scrollPane = new JScrollPane(getFontStyleList());
    scrollPane.getVerticalScrollBar().setFocusable(false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(getFontStyleTextField(), BorderLayout.NORTH);
    p.add(scrollPane, BorderLayout.CENTER);
    JLabel label = new JLabel(("Font Style"));
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setHorizontalTextPosition(JLabel.LEFT);
    label.setLabelFor(getFontStyleTextField());
    label.setDisplayedMnemonic('Y');
    fontStylePanel.add(label, BorderLayout.NORTH);
    fontStylePanel.add(p, BorderLayout.CENTER);
  }
  return fontStylePanel;
}

代码示例来源:origin: org.netbeans.api/org-openide-dialogs

JPanel panel = new JPanel();
panel.setOpaque (false);
JLabel textLabel = new JLabel();
Mnemonics.setLocalizedText(textLabel, text);
textLabel.setLabelFor(textField);

代码示例来源:origin: com.google.code.findbugs/findbugs

private void addField(JPanel p, GridBagConstraints c, int y, String lbl, JComponent field) {
  c.gridy = y;
  JLabel l = new JLabel(lbl, SwingConstants.TRAILING);
  l.setLabelFor(field);
  c.anchor = GridBagConstraints.LINE_END;
  c.gridx = 0;
  p.add(l, c);
  c.anchor = GridBagConstraints.LINE_START;
  c.gridx = 1;
  p.add(field, c);
}
private JPanel createPropertiesPane() {

代码示例来源:origin: skylot/jadx

public ProgressPanel(final MainWindow mainWindow, boolean showCancelButton) {
  progressLabel = new JLabel();
  progressBar = new JProgressBar(0, 100);
  progressBar.setIndeterminate(true);
  progressBar.setStringPainted(false);
  progressLabel.setLabelFor(progressBar);
  setBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
  setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
  setVisible(false);
  add(progressLabel);
  add(progressBar);
  if (showCancelButton) {
    JButton cancelButton = new JButton(ICON_CANCEL);
    cancelButton.setPreferredSize(new Dimension(ICON_CANCEL.getIconWidth(), ICON_CANCEL.getIconHeight()));
    cancelButton.setToolTipText("Cancel background jobs");
    cancelButton.setBorderPainted(false);
    cancelButton.setFocusPainted(false);
    cancelButton.setContentAreaFilled(false);
    cancelButton.addActionListener(new ActionListener() {
      @Override
      public void actionPerformed(ActionEvent e) {
        mainWindow.cancelBackgroundJobs();
      }
    });
    add(cancelButton);
  }
}

代码示例来源:origin: io.github.dheid/fontchooser

private void addSizeLabel() {
  sizeLabel.setLabelFor(sizePane);
  sizeLabel.setDisplayedMnemonic(ResourceBundleUtil.getFirstChar(resourceBundle, "font.size.mnemonic"));
  sizeLabel.setText(resourceBundle.getString("font.size"));
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.anchor = GridBagConstraints.LINE_START;
  gridBagConstraints.insets = new Insets(0, 0, 5, 0);
  fontPanel.add(sizeLabel, gridBagConstraints);
}

代码示例来源:origin: deathmarine/Luyten

protected JPanel getFontSizePanel() {
  if (fontSizePanel == null) {
    fontSizePanel = new JPanel();
    fontSizePanel.setLayout(new BorderLayout());
    fontSizePanel.setPreferredSize(new Dimension(70, 130));
    fontSizePanel.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    JScrollPane scrollPane = new JScrollPane(getFontSizeList());
    scrollPane.getVerticalScrollBar().setFocusable(false);
    scrollPane.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    JPanel p = new JPanel();
    p.setLayout(new BorderLayout());
    p.add(getFontSizeTextField(), BorderLayout.NORTH);
    p.add(scrollPane, BorderLayout.CENTER);
    JLabel label = new JLabel(("Font Size"));
    label.setHorizontalAlignment(JLabel.LEFT);
    label.setHorizontalTextPosition(JLabel.LEFT);
    label.setLabelFor(getFontSizeTextField());
    label.setDisplayedMnemonic('S');
    fontSizePanel.add(label, BorderLayout.NORTH);
    fontSizePanel.add(p, BorderLayout.CENTER);
  }
  return fontSizePanel;
}

代码示例来源:origin: magefree/mage

jLabel6.setText("Step 2:");
lblAuthToken.setLabelFor(txtAuthToken);
lblAuthToken.setText("Auth token:");
lblPassword.setLabelFor(txtPassword);
lblPassword.setText("New password:");
lblPasswordConfirmation.setLabelFor(txtPasswordConfirmation);
lblPasswordConfirmation.setText("New password:");
lblPasswordConfirmationReasoning.setLabelFor(txtPasswordConfirmation);
lblPasswordConfirmationReasoning.setText("(confirmation)");
jLabel5.setText("Step 1:");
lblEmail.setLabelFor(txtEmail);
lblEmail.setText("Email:");
btnCancel.addActionListener(evt -> btnCancelActionPerformed(evt));
lblServer.setLabelFor(txtServer);
lblServer.setText("Server:");
lblPort.setLabelFor(txtPort);
lblPort.setText("Port:");

代码示例来源:origin: uk.org.mygrid.taverna.processors/taverna-rserv-processor

protected void addField(JPanel panel, String labelString, JTextField field) {
  JLabel label = new JLabel(labelString, JLabel.TRAILING);
  label.setPreferredSize(new Dimension(0, 0));
  field.setPreferredSize(new Dimension(0, 0));
  panel.add(label);
  label.setLabelFor(field);
  field.addFocusListener(this);
  // FIXME: Not i18n compatible to use label as identifier (like the rest
  // of Taverna)
  panel.add(field);
}

代码示例来源:origin: cmusphinx/sphinx4

JLabel filenameLabel = new JLabel("Filename:");
filenameLabel.setLabelFor(filename);

代码示例来源:origin: io.github.dheid/fontchooser

private void addStyleLabel() {
  styleLabel.setLabelFor(stylePane);
  styleLabel.setDisplayedMnemonic(ResourceBundleUtil.getFirstChar(resourceBundle, "font.style.mnemonic"));
  styleLabel.setText(resourceBundle.getString("font.style"));
  GridBagConstraints gridBagConstraints = new GridBagConstraints();
  gridBagConstraints.anchor = GridBagConstraints.LINE_START;
  gridBagConstraints.insets = new Insets(0, 0, 5, DEFAULT_SPACE);
  fontPanel.add(styleLabel, gridBagConstraints);
}

代码示例来源:origin: skylot/jadx

textPane.setBorder(BorderFactory.createEmptyBorder(15, 15, 15, 15));
JPanel controlPane = new JPanel();
controlPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
final JComboBox<Level> cb = new JComboBox<>(LEVEL_ITEMS);
  registerLogListener();
});
JLabel levelLabel = new JLabel(NLS.str("log_viewer.log_level"));
levelLabel.setLabelFor(cb);
controlPane.add(levelLabel);
controlPane.add(cb);

代码示例来源:origin: magefree/mage

pnlProxyAuth = new javax.swing.JPanel();
lblServer.setLabelFor(txtServer);
lblServer.setText("Server:");
lblPort.setLabelFor(txtPort);
lblPort.setText("Port:");
lblProxyType.setLabelFor(cbProxyType);
lblProxyType.setText("Proxy:");
lblProxyServer.setLabelFor(txtProxyServer);
lblProxyServer.setText("Server:");
lblProxyPort.setLabelFor(txtProxyPort);
lblProxyPort.setText("Port:");
);
lblProxyUserName.setLabelFor(txtProxyUserName);
lblProxyUserName.setText("User Name:");
);
lblPassword.setLabelFor(txtPassword);
lblPassword.setText("Password:");

代码示例来源:origin: otros-systems/otroslogviewer

private void addLabel(String string, char c, JComponent jComponent) {
 JLabel label = new JLabel(string);
 p.add(label);
 label.setDisplayedMnemonic(c);
 label.setLabelFor(jComponent);
 p.add(jComponent, "growx, wrap");
}

代码示例来源:origin: wiztools/rest-client

JLabel jl_url = new JLabel("URL: ");
jl_url.setLabelFor(jcb_url);
jl_url.setDisplayedMnemonic('u');
rest_ui.getFrame().getRootPane().setDefaultButton(jb_request);

相关文章

JLabel类方法