javax.swing.JButton.getText()方法的使用及代码示例

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

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

JButton.getText介绍

暂无

代码示例

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

public void run() {
  if (findButton.getText().equals("Stop")) {
    if (tmp_thread != null)
      tmp_thread.interrupt();
      initProgressBar(Collections.list(entLength).size());
      Enumeration<JarEntry> ent = jfile.entries();
      while (ent.hasMoreElements() && findButton.getText().equals("Stop")) {
        JarEntry entry = ent.nextElement();
        String name = entry.getName();
      if (findButton.getText().equals("Stop")) {
        setStatus("Done.");
        findButton.setText("Find");

代码示例来源:origin: tomighty/tomighty

public void file(File file) {
  this.file = file;
  String text;
  if(file == null) {
    text = defaultButton.getText();
  } else {
    text = file.getName();
  }
  filenameField.setText(text);
  defaultButton.setVisible(file != null);
}

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

public void pressOKYesOrDone() {
  if (btnLeft.getText().equals("OK") || btnLeft.getText().equals("Yes")) {
    btnLeft.doClick();
  } else if (btnRight.getText().equals("OK") || btnRight.getText().equals("Yes") || btnRight.getText().equals("Done")) {
    btnRight.doClick();
  }
}

代码示例来源:origin: fossasia/neurolab-desktop

@Override
  public void actionPerformed(ActionEvent e) {
    if (running) {
      String sendCmd = "I";
      if (buttonMode.getText().contains("I"))
        sendCmd = "S";
      boolean response = serialPortInterface.sendCommand(sendCmd);
      System.out.println("sent command: " + response);
      buttonMode.setText("mode=" + sendCmd);
    }
  }
});

代码示例来源:origin: opensourceBIM/BIMserver

@Override
  public void actionPerformed(ActionEvent e) {
    if (startStopButton.getText().equals("Start")) {
      new Thread(new Runnable() {
        @Override
        public void run() {
          if (jvmField.getText().equalsIgnoreCase("default") || new File(jvmField.getText()).exists()) {
            setComponentsEnabled(false);
            File file = expand();
            startStopButton.setText("Stop");
            start(file, addressField.getText(), portField.getText(), heapSizeField.getText(), stackSizeField.getText(), jvmField.getText(), homeDirField.getText());
          } else {
            JOptionPane.showMessageDialog(Starter.this, "JVM field should contain a valid JVM directory, or 'default' for the default JVM");
          }
        }
      }, "BIMserver Starter Thread").start();
    } else if (startStopButton.getText().equals("Stop")) {
      if (exec != null) {
        exec.destroy();
        System.out.println("Server has been shut down");
        exec = null;
        startStopButton.setText("Start");
        setComponentsEnabled(true);
      }
    }
  }
});

代码示例来源:origin: geotools/geotools

/**
 * Overridden to get a reference to the OK button created by the super-class method.
 *
 * @return the button panel
 */
@Override
protected JPanel createButtonPanel() {
  JPanel panel = super.createButtonPanel();
  for (JButton btn : DialogUtils.getChildComponents(JButton.class, panel, false)) {
    if ("OK".equals(btn.getText())) {
      okButton = btn;
      break;
    }
  }
  if (okButton == null) {
    throw new IllegalStateException("Failed to initialize the OK button correctly");
  }
  okButton.setEnabled(false);
  return panel;
}

代码示例来源:origin: fossasia/neurolab-desktop

@Override
  public void actionPerformed(ActionEvent e) {
    if (buttonRecord.getText().equals("record")) {
      JFileChooser chooser = new JFileChooser();
      int retrieval = chooser.showSaveDialog(null);
      if ((retrieval == JFileChooser.APPROVE_OPTION) && (chooser.getSelectedFile() != null)) {
        System.out.println("saving raw data stream to " + chooser.getSelectedFile().toString());
        serialPortInterface.record(chooser.getSelectedFile().toString());
        // fileOutputTask.setFileName(chooser.getSelectedFile().toString());
        // fileOutputTask.setWrite(true);
        buttonRecord.setText("stop");
        buttonRecord.setBackground(new Color(180, 60, 60));
      }
    } else {
      // fileOutputTask.setWrite(false);
      // fileOutputTask.stop();
      serialPortInterface.stopRecording();
      buttonRecord.setText("record");
      buttonRecord.setBackground(new Color(60, 255, 120));
    }
  }
});

代码示例来源:origin: winder/Universal-G-Code-Sender

private void opencloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opencloseButtonActionPerformed
  if (this.openCloseButton.getText().equalsIgnoreCase(Localization.getString("open"))) {
    String firmware = this.firmwareCombo.getSelectedItem().toString();
    String port = portCombo.getSelectedItem().toString();
    int baudRate = Integer.parseInt(baudCombo.getSelectedItem().toString());
    try {
      this.backend.connect(firmware, port, baudRate);
    } catch (Exception e) {
      logger.log(Level.WARNING, "Problem during backend.connect.", e);
      displayErrorDialog(e.getMessage());
    }
  } else {
    try {
      this.backend.disconnect();
    } catch (Exception e) {
      displayErrorDialog(e.getMessage());
    }
  }
}

代码示例来源:origin: fossasia/neurolab-desktop

@Override
  public void actionPerformed(ActionEvent e) {
    if (buttonFir.getText().contains("true"))
    {
      buttonFir.setText("fir=false");
      fir = false;
    }
    else
    {
      buttonFir.setText("fir=true");
      fir = true;
    }
    
    for (Task task : tasks)
    {
      if (task instanceof FFTPreprocessor)
        ((FFTPreprocessor)task).enableFIRFilter(fir);
    }
    config.setPref(Config.server_settings, String.valueOf(Config.server_settings_params.fir), fir?"1":"0");
    config.store();
  }
});

代码示例来源:origin: winder/Universal-G-Code-Sender

private void sendPauseResumeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sendButtonActionPerformed
  try {
    if (sendPauseResumeButton.getText().equals(Localization.getString("mainWindow.swing.sendButton"))) {
      this.backend.send();
    } else {
      this.backend.pauseResume();
    }
  } catch (Exception e) {
    displayErrorDialog(e.getMessage());
  }
}

代码示例来源:origin: winder/Universal-G-Code-Sender

private void browseCancelButtonActionPerformed(java.awt.event.ActionEvent evt) {
  try {
    if (browseCancelButton.getText().equals(Localization.getString("mainWindow.swing.browseButton"))) {
      openFileChooser();
    } else {
      backend.cancel();
    }
  } catch (Exception e) {
    displayErrorDialog(e.getMessage());
  }
}

代码示例来源:origin: winder/Universal-G-Code-Sender

private void opencloseButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_opencloseButtonActionPerformed
  if( this.opencloseButton.getText().equalsIgnoreCase(Localization.getString("open")) ) {
    this.commandTable.clear();
    this.sentRowsValueLabel.setText("0");
    String firmware = this.firmwareComboBox.getSelectedItem().toString();
    String port = commPortComboBox.getSelectedItem().toString();
    int baudRate = Integer.parseInt(baudrateSelectionComboBox.getSelectedItem().toString());
    
    try {
      this.backend.connect(firmware, port, baudRate);
      
      // Let the command field grab focus.
      commandTextField.grabFocus();
    } catch (Exception e) {
      e.printStackTrace();
      displayErrorDialog(e.getMessage());
    }
  } else {
    try {
      this.backend.disconnect();
    } catch (Exception e) {
      displayErrorDialog(e.getMessage());
    }
  }
}//GEN-LAST:event_opencloseButtonActionPerformed

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

@Override
public void actionPerformed(ActionEvent e)
{
  Object source = e.getSource();
  if (source instanceof JButton) {
    JButton btn = (JButton)source;
    String butSrcTxt = btn.getText();
  }

}

代码示例来源:origin: freeplane/freeplane

@Override
  public void setValue(final String value) {
    mButton.setText(value);
    mButton.setToolTipText(mButton.getText());
  }
}

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

JPanel panel = new JPanel(new GridLayout(3, 3));
for (int i = 1; i <= 9; i++) {
  JButton button = new JButton("Button " + i);
  panel.add(button);

  // save it to a map for easy retrieval
  buttonMap.put(button.getText(), button);
}

代码示例来源:origin: undera/jmeter-plugins

@Override
public Object getTransferData(DataFlavor flavor) {
  if (isDataFlavorSupported(flavor)) {
    return "|" + ((JButton) e.getSource()).getText() + "|";
  }
  return null;
}

代码示例来源:origin: mucommander/mucommander

/**
 * Convenience method that returns a mnemonic for the specified button.
 * Yields to the same result as if {@link #getMnemonic(String)} were called with JButton.getText().
 *
 * @param button the button to get a mnemonic for
 * @return the character to be used as a mnemonic, always in lower case, 0 if no
 * mnemonic was available for this piece of text. 0 is returned if a <code>null</code> string is passed.
 */
public char getMnemonic(JButton button) {
  return getMnemonic(button.getText());
}

代码示例来源:origin: freeplane/freeplane

private JButton addAction(Action a) {
  final JButton menuItem = new JButton(a);
  menuItem.setToolTipText(menuItem.getText());
  menuItem.setText(null);
  add(menuItem);
  menuItem.setMargin(nullInsets);
  return menuItem;
}

代码示例来源:origin: freeplane/freeplane

/**
 * JDayChooser is the ActionListener for all day buttons.
 *
 * @param e
 *            the ActionEvent
 */
public void actionPerformed(final ActionEvent e) {
  final JButton button = (JButton) e.getSource();
  final String buttonText = button.getText();
  final int day = new Integer(buttonText).intValue();
  setDay(day);
}

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

@Override
 protected boolean isMatching(JButton component) {
  return component.getText().equalsIgnoreCase(text);
 }
};

相关文章

JButton类方法