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

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

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

JButton.setEnabled介绍

暂无

代码示例

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

JButton startButton = new JButton("Start");
startButton.addActionListener(new ActionListener() {
   public void actionPerformed(ActionEvent ae) {
    startButton.setEnabled(false);
    stopButton.setEnabled(true);
   }
  }
 );

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeFoundStatsBox() {
 JPanel foundStatsBox = new JPanel();
 foundStatsBox.setLayout(new GridBagLayout());
 Box labelBox = Box.createHorizontalBox();
 foundStats = new JLabel(" ");
 labelBox.add(foundStats);
 historyButton = new JButton("Statistics");
 historyButton.setEnabled(false);
 historyButton.addActionListener(this);
 GridBagConstraints c = new GridBagConstraints();
 c.fill = GridBagConstraints.BOTH;
 c.weightx = 1.7;
 foundStatsBox.add(labelBox,c);
 c.weightx = .3;
 c.gridwidth = 1;
 foundStatsBox.add(historyButton);
 return foundStatsBox;
}

代码示例来源:origin: 4thline/cling

protected void initializeLoggingToolbar() {
  toolBar.setMargin(new Insets(5, 0, 5, 0));
  toolBar.setFloatable(false);
  toolBar.add(copyButton);
  copyButton.setFocusable(false);
  copyButton.setEnabled(false);
  copyButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      StringBuilder sb = new StringBuilder();
      List<StateVariableValue> messages = getSelectedValue();
      for (StateVariableValue message : messages) {
        sb.append(message.toString()).append("\n");
      }
      Application.copyToClipboard(sb.toString());
    }
  });
  toolBar.setFloatable(false);
  toolBar.add(copyButton);
  toolBar.add(Box.createHorizontalGlue());
}

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

add(new JScrollPane(table), BorderLayout.CENTER);
button = new JButton("Load Data");
button.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
LOG.info("START loadData method");
button.setEnabled(false);
  LOG.log(Level.SEVERE, "Exception in Load Data", e);
button.setEnabled(true);

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

cancel.setEnabled(false);
  break; // Need further action below.
final JTextArea warningArea = new JTextArea();
final JScrollPane scroll = new JScrollPane(warningArea);
final JPanel namedArea = new JPanel(new BorderLayout());
JProgressWindow.this.warningArea = warningArea;
warningArea.setFont(Font.getFont("Monospaced"));
namedArea.setBorder(
    BorderFactory.createEmptyBorder(0, HMARGIN, VMARGIN, HMARGIN));
namedArea.add(
    new JLabel(getString(VocabularyKeys.WARNING)), BorderLayout.NORTH);
namedArea.add(scroll, BorderLayout.CENTER);
content.add(namedArea, BorderLayout.CENTER);
if (window instanceof JDialog) {

代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin

this.tableView.setModelAndUpdateColumns(this.modelList);
tableViewPanel.add(ToolbarDecorator.createDecorator(this.tableView)
  .disableAddAction()
  .disableDownAction()
this.generateButton.addActionListener(e -> update());
});
this.closeButton.addActionListener(e -> {
  setEnabled(false);
  dispose();
});
this.buttonCopy.addActionListener(e -> {
  if(StringUtils.isBlank(textAreaOutput.getText())) {
    return;
  this.buttonInsert.setEnabled(true);
  this.buttonInsert.setVisible(true);
  this.buttonInsert.setEnabled(false);
  this.buttonInsert.setVisible(false);

代码示例来源:origin: kiegroup/optaplanner

public void addShiftAssignment(ShiftAssignment shiftAssignment) {
  Shift shift = shiftAssignment.getShift();
  JPanel shiftPanel = shiftPanelMap.get(shift);
  JButton shiftAssignmentButton = SwingUtils.makeSmallButton(new JButton(new ShiftAssignmentAction(shiftAssignment)));
  shiftAssignmentButton.setEnabled(shiftPanel.isEnabled());
  if (employee != null) {
    if (employee.getDayOffRequestMap().containsKey(shift.getShiftDate())
        || employee.getShiftOffRequestMap().containsKey(shift)) {
      shiftAssignmentButton.setForeground(TangoColorFactory.SCARLET_1);
    }
  }
  Color color = nurseRosteringPanel.determinePlanningEntityColor(shiftAssignment, shift.getShiftType());
  shiftAssignmentButton.setBackground(color);
  String toolTip = nurseRosteringPanel.determinePlanningEntityTooltip(shiftAssignment);
  shiftAssignmentButton.setToolTipText(toolTip);
  shiftPanel.add(shiftAssignmentButton);
  shiftPanel.repaint();
  shiftAssignmentButtonMap.put(shiftAssignment, shiftAssignmentButton);
}

代码示例来源:origin: stanfordnlp/CoreNLP

private JPanel makeTregexButtonBox() {
 JPanel buttonBox = new JPanel();
 buttonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
 buttonBox.setLayout(new GridBagLayout());
 help = new JButton("Help");
 help.addActionListener(this);
 cancel = new JButton("Cancel");
 cancel.setEnabled(false);
 cancel.addActionListener(this);
 findMatches = new JButton("Search");
 findMatches.addActionListener(this);
 buttonBox.add(findMatches,buttonConstraints);
 buttonBox.add(cancel,buttonConstraints);
 buttonBox.add(help,buttonConstraints);

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

final JButton okay = new JButton("Ok");
okay.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
okay.setEnabled(false);
final JButton cancel = new JButton("Cancel");
cancel.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent e) {
field.getDocument().addDocumentListener(new DocumentListener() {
  protected void update() {
    okay.setEnabled(field.getText().length() > 0);

代码示例来源:origin: fr.avianey.apache-xmlgraphics/batik

/**
 * Creates the buttons panel
 */
protected JPanel createButtonsPanel() {
  JPanel  p = new JPanel(new FlowLayout());
  p.add(okButton = buttonFactory.createJButton("OKButton"));
  p.add(buttonFactory.createJButton("CancelButton"));
  p.add(clearButton = buttonFactory.createJButton("ClearButton"));
  okButton.setEnabled(false);
  clearButton.setEnabled(false);
  return p;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private void addRunButton( JPanel buttonPanel )
{
 _btnViewSource = new LabButton( "View Source" );
 _btnViewSource.setMnemonic( 'V' );
 _btnViewSource.addActionListener( new ViewSourceAction() );
 buttonPanel.add( _btnViewSource );
 getRootPane().setDefaultButton( _btnViewSource );
 _btnViewSource.setEnabled( false );
}

代码示例来源:origin: 4thline/cling

protected void initializeToolBar(LogController.Expiration expiration) {
  configureButton.setFocusable(false);
  configureButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      centerWindowEvent.fire(new CenterWindow(logCategorySelector));
  clearButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      logTableModel.clearMessages();
  copyButton.setEnabled(false);
  copyButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
      StringBuilder sb = new StringBuilder();
  expandButton.setEnabled(false);
  expandButton.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {

代码示例来源:origin: io.ultreia.java4all.i18n/i18n-editor

private JButton addAction(JPanel actions, Action action) {
  JButton result = new JButton(action);
  actions.add(result);
  result.setEnabled(false);
  result.setDisplayedMnemonicIndex(result.getText().length() - 2);
  return result;
}

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

JButton button1 = new JButton("OK");
 button1.setEnabled(false);
 button1.setAlignmentX(-1);
 JButton button2 = new JButton("Apply");
 button1.setEnabled(false);
 button1.setAlignmentX(-1);

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

playButton = new JButton("Play");
playButton.setEnabled(true);
playButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    player.play(audioPanel.getSelectionStart(),
recordButton = new JButton("Record");
recordButton.setEnabled(true);
recordButton.addActionListener(recordListener);
zoomInButton = new JButton("Zoom In");
zoomInButton.setEnabled(true);
zoomInButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
    zoomIn();
zoomOutButton = new JButton("Zoom Out");
zoomOutButton.setEnabled(true);
zoomOutButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {
zoomResetButton = new JButton("Reset Size");
zoomResetButton.setEnabled(true);
zoomResetButton.addActionListener(new ActionListener() {
  public void actionPerformed(ActionEvent e) {

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

private JButton createMacroButton(int i) {
  JButton button = new JButton(i+"");
  button.setEnabled(false);
  this.setToolTipText(Localization.getString("macroPanel.button"));
  button.addActionListener((ActionEvent evt) -> {
    customGcodeButtonActionPerformed(i);
  });
  return button;
}

代码示例来源:origin: apache/batik

/**
 * Creates the buttons panel
 */
protected JPanel createButtonsPanel() {
  JPanel  p = new JPanel(new FlowLayout());
  p.add(okButton = buttonFactory.createJButton("OKButton"));
  p.add(buttonFactory.createJButton("CancelButton"));
  p.add(clearButton = buttonFactory.createJButton("ClearButton"));
  okButton.setEnabled(false);
  clearButton.setEnabled(false);
  return p;
}

代码示例来源:origin: org.gosu-lang.gosu/gosu-lab

private void addSaveButton( JPanel buttonPanel )
{
 _btnSave = new LabButton( "Save" );
 _btnSave.setMnemonic( 'S' );
 _btnSave.addActionListener(
  e -> {
   save();
   close();
  } );
 buttonPanel.add( _btnSave );
 getRootPane().setDefaultButton( _btnSave );
 _btnSave.setEnabled( false );
}

代码示例来源:origin: 4thline/cling

invocationToolBar.setFloatable(false);
invokeActionButton.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent actionEvent) {
invocationToolBar.add(invokeActionButton);
cancelActionButton.addActionListener(new ActionListener() {
  @Override
  public void actionPerformed(ActionEvent actionEvent) {
cancelActionButton.setEnabled(false);
cancelActionButton.setPreferredSize(new Dimension(5000, 25));
invocationToolBar.add(cancelActionButton);

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

JButton button_ok = makeButton("OK", false, -1);
JButton button_apply = makeButton("Apply", true, 1);
// what exactly is being set here?

...

// much later:
private static JButton makeButton(String name, boolean enabled,
    int alignment)
{
  JButton button = new JButton(name);
  button.setEnabled(enabled);
  button.setAlignmentX(alignment);
  return button;
}

相关文章

微信公众号

最新文章

更多

JButton类方法