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

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

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

JButton.setEnabled介绍

暂无

代码示例

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

  1. JButton startButton = new JButton("Start");
  2. startButton.addActionListener(new ActionListener() {
  3. public void actionPerformed(ActionEvent ae) {
  4. startButton.setEnabled(false);
  5. stopButton.setEnabled(true);
  6. }
  7. }
  8. );

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

  1. private JPanel makeFoundStatsBox() {
  2. JPanel foundStatsBox = new JPanel();
  3. foundStatsBox.setLayout(new GridBagLayout());
  4. Box labelBox = Box.createHorizontalBox();
  5. foundStats = new JLabel(" ");
  6. labelBox.add(foundStats);
  7. historyButton = new JButton("Statistics");
  8. historyButton.setEnabled(false);
  9. historyButton.addActionListener(this);
  10. GridBagConstraints c = new GridBagConstraints();
  11. c.fill = GridBagConstraints.BOTH;
  12. c.weightx = 1.7;
  13. foundStatsBox.add(labelBox,c);
  14. c.weightx = .3;
  15. c.gridwidth = 1;
  16. foundStatsBox.add(historyButton);
  17. return foundStatsBox;
  18. }

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

  1. protected void initializeLoggingToolbar() {
  2. toolBar.setMargin(new Insets(5, 0, 5, 0));
  3. toolBar.setFloatable(false);
  4. toolBar.add(copyButton);
  5. copyButton.setFocusable(false);
  6. copyButton.setEnabled(false);
  7. copyButton.addActionListener(new ActionListener() {
  8. public void actionPerformed(ActionEvent e) {
  9. StringBuilder sb = new StringBuilder();
  10. List<StateVariableValue> messages = getSelectedValue();
  11. for (StateVariableValue message : messages) {
  12. sb.append(message.toString()).append("\n");
  13. }
  14. Application.copyToClipboard(sb.toString());
  15. }
  16. });
  17. toolBar.setFloatable(false);
  18. toolBar.add(copyButton);
  19. toolBar.add(Box.createHorizontalGlue());
  20. }

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

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

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

  1. cancel.setEnabled(false);
  2. break; // Need further action below.
  3. final JTextArea warningArea = new JTextArea();
  4. final JScrollPane scroll = new JScrollPane(warningArea);
  5. final JPanel namedArea = new JPanel(new BorderLayout());
  6. JProgressWindow.this.warningArea = warningArea;
  7. warningArea.setFont(Font.getFont("Monospaced"));
  8. namedArea.setBorder(
  9. BorderFactory.createEmptyBorder(0, HMARGIN, VMARGIN, HMARGIN));
  10. namedArea.add(
  11. new JLabel(getString(VocabularyKeys.WARNING)), BorderLayout.NORTH);
  12. namedArea.add(scroll, BorderLayout.CENTER);
  13. content.add(namedArea, BorderLayout.CENTER);
  14. if (window instanceof JDialog) {

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

  1. this.tableView.setModelAndUpdateColumns(this.modelList);
  2. tableViewPanel.add(ToolbarDecorator.createDecorator(this.tableView)
  3. .disableAddAction()
  4. .disableDownAction()
  5. this.generateButton.addActionListener(e -> update());
  6. });
  7. this.closeButton.addActionListener(e -> {
  8. setEnabled(false);
  9. dispose();
  10. });
  11. this.buttonCopy.addActionListener(e -> {
  12. if(StringUtils.isBlank(textAreaOutput.getText())) {
  13. return;
  14. this.buttonInsert.setEnabled(true);
  15. this.buttonInsert.setVisible(true);
  16. this.buttonInsert.setEnabled(false);
  17. this.buttonInsert.setVisible(false);

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

  1. public void addShiftAssignment(ShiftAssignment shiftAssignment) {
  2. Shift shift = shiftAssignment.getShift();
  3. JPanel shiftPanel = shiftPanelMap.get(shift);
  4. JButton shiftAssignmentButton = SwingUtils.makeSmallButton(new JButton(new ShiftAssignmentAction(shiftAssignment)));
  5. shiftAssignmentButton.setEnabled(shiftPanel.isEnabled());
  6. if (employee != null) {
  7. if (employee.getDayOffRequestMap().containsKey(shift.getShiftDate())
  8. || employee.getShiftOffRequestMap().containsKey(shift)) {
  9. shiftAssignmentButton.setForeground(TangoColorFactory.SCARLET_1);
  10. }
  11. }
  12. Color color = nurseRosteringPanel.determinePlanningEntityColor(shiftAssignment, shift.getShiftType());
  13. shiftAssignmentButton.setBackground(color);
  14. String toolTip = nurseRosteringPanel.determinePlanningEntityTooltip(shiftAssignment);
  15. shiftAssignmentButton.setToolTipText(toolTip);
  16. shiftPanel.add(shiftAssignmentButton);
  17. shiftPanel.repaint();
  18. shiftAssignmentButtonMap.put(shiftAssignment, shiftAssignmentButton);
  19. }

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

  1. private JPanel makeTregexButtonBox() {
  2. JPanel buttonBox = new JPanel();
  3. buttonBox.setComponentOrientation(ComponentOrientation.RIGHT_TO_LEFT);
  4. buttonBox.setLayout(new GridBagLayout());
  5. help = new JButton("Help");
  6. help.addActionListener(this);
  7. cancel = new JButton("Cancel");
  8. cancel.setEnabled(false);
  9. cancel.addActionListener(this);
  10. findMatches = new JButton("Search");
  11. findMatches.addActionListener(this);
  12. buttonBox.add(findMatches,buttonConstraints);
  13. buttonBox.add(cancel,buttonConstraints);
  14. buttonBox.add(help,buttonConstraints);

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

  1. final JButton okay = new JButton("Ok");
  2. okay.addActionListener(new ActionListener() {
  3. @Override
  4. public void actionPerformed(ActionEvent e) {
  5. okay.setEnabled(false);
  6. final JButton cancel = new JButton("Cancel");
  7. cancel.addActionListener(new ActionListener() {
  8. @Override
  9. public void actionPerformed(ActionEvent e) {
  10. field.getDocument().addDocumentListener(new DocumentListener() {
  11. protected void update() {
  12. okay.setEnabled(field.getText().length() > 0);

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

  1. /**
  2. * Creates the buttons panel
  3. */
  4. protected JPanel createButtonsPanel() {
  5. JPanel p = new JPanel(new FlowLayout());
  6. p.add(okButton = buttonFactory.createJButton("OKButton"));
  7. p.add(buttonFactory.createJButton("CancelButton"));
  8. p.add(clearButton = buttonFactory.createJButton("ClearButton"));
  9. okButton.setEnabled(false);
  10. clearButton.setEnabled(false);
  11. return p;
  12. }

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

  1. private void addRunButton( JPanel buttonPanel )
  2. {
  3. _btnViewSource = new LabButton( "View Source" );
  4. _btnViewSource.setMnemonic( 'V' );
  5. _btnViewSource.addActionListener( new ViewSourceAction() );
  6. buttonPanel.add( _btnViewSource );
  7. getRootPane().setDefaultButton( _btnViewSource );
  8. _btnViewSource.setEnabled( false );
  9. }

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

  1. protected void initializeToolBar(LogController.Expiration expiration) {
  2. configureButton.setFocusable(false);
  3. configureButton.addActionListener(new ActionListener() {
  4. public void actionPerformed(ActionEvent e) {
  5. centerWindowEvent.fire(new CenterWindow(logCategorySelector));
  6. clearButton.addActionListener(new ActionListener() {
  7. public void actionPerformed(ActionEvent e) {
  8. logTableModel.clearMessages();
  9. copyButton.setEnabled(false);
  10. copyButton.addActionListener(new ActionListener() {
  11. public void actionPerformed(ActionEvent e) {
  12. StringBuilder sb = new StringBuilder();
  13. expandButton.setEnabled(false);
  14. expandButton.addActionListener(new ActionListener() {
  15. public void actionPerformed(ActionEvent e) {

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

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

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

  1. JButton button1 = new JButton("OK");
  2. button1.setEnabled(false);
  3. button1.setAlignmentX(-1);
  4. JButton button2 = new JButton("Apply");
  5. button1.setEnabled(false);
  6. button1.setAlignmentX(-1);

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

  1. playButton = new JButton("Play");
  2. playButton.setEnabled(true);
  3. playButton.addActionListener(new ActionListener() {
  4. public void actionPerformed(ActionEvent e) {
  5. player.play(audioPanel.getSelectionStart(),
  6. recordButton = new JButton("Record");
  7. recordButton.setEnabled(true);
  8. recordButton.addActionListener(recordListener);
  9. zoomInButton = new JButton("Zoom In");
  10. zoomInButton.setEnabled(true);
  11. zoomInButton.addActionListener(new ActionListener() {
  12. public void actionPerformed(ActionEvent e) {
  13. zoomIn();
  14. zoomOutButton = new JButton("Zoom Out");
  15. zoomOutButton.setEnabled(true);
  16. zoomOutButton.addActionListener(new ActionListener() {
  17. public void actionPerformed(ActionEvent e) {
  18. zoomResetButton = new JButton("Reset Size");
  19. zoomResetButton.setEnabled(true);
  20. zoomResetButton.addActionListener(new ActionListener() {
  21. public void actionPerformed(ActionEvent e) {

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

  1. private JButton createMacroButton(int i) {
  2. JButton button = new JButton(i+"");
  3. button.setEnabled(false);
  4. this.setToolTipText(Localization.getString("macroPanel.button"));
  5. button.addActionListener((ActionEvent evt) -> {
  6. customGcodeButtonActionPerformed(i);
  7. });
  8. return button;
  9. }

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

  1. /**
  2. * Creates the buttons panel
  3. */
  4. protected JPanel createButtonsPanel() {
  5. JPanel p = new JPanel(new FlowLayout());
  6. p.add(okButton = buttonFactory.createJButton("OKButton"));
  7. p.add(buttonFactory.createJButton("CancelButton"));
  8. p.add(clearButton = buttonFactory.createJButton("ClearButton"));
  9. okButton.setEnabled(false);
  10. clearButton.setEnabled(false);
  11. return p;
  12. }

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

  1. private void addSaveButton( JPanel buttonPanel )
  2. {
  3. _btnSave = new LabButton( "Save" );
  4. _btnSave.setMnemonic( 'S' );
  5. _btnSave.addActionListener(
  6. e -> {
  7. save();
  8. close();
  9. } );
  10. buttonPanel.add( _btnSave );
  11. getRootPane().setDefaultButton( _btnSave );
  12. _btnSave.setEnabled( false );
  13. }

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

  1. invocationToolBar.setFloatable(false);
  2. invokeActionButton.addActionListener(new ActionListener() {
  3. @Override
  4. public void actionPerformed(ActionEvent actionEvent) {
  5. invocationToolBar.add(invokeActionButton);
  6. cancelActionButton.addActionListener(new ActionListener() {
  7. @Override
  8. public void actionPerformed(ActionEvent actionEvent) {
  9. cancelActionButton.setEnabled(false);
  10. cancelActionButton.setPreferredSize(new Dimension(5000, 25));
  11. invocationToolBar.add(cancelActionButton);

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

  1. JButton button_ok = makeButton("OK", false, -1);
  2. JButton button_apply = makeButton("Apply", true, 1);
  3. // what exactly is being set here?
  4. ...
  5. // much later:
  6. private static JButton makeButton(String name, boolean enabled,
  7. int alignment)
  8. {
  9. JButton button = new JButton(name);
  10. button.setEnabled(enabled);
  11. button.setAlignmentX(alignment);
  12. return button;
  13. }

相关文章

JButton类方法