List of usage examples for javax.swing JButton setEnabled
public void setEnabled(boolean b)
From source file:com.diversityarrays.kdxplore.vistool.AbstractVisToolPanel.java
protected void updateRefreshButton() { JButton refreshButton = toolBar == null ? null : toolBar.refreshButton; if (refreshButton != null) { refreshButton.setEnabled(true); }/*from w ww. j a v a2 s .c o m*/ }
From source file:net.pandoragames.far.ui.swing.component.ButtonPanel.java
/** * Initialises the BUTTON panel./*from ww w.j a v a2s .c o m*/ * @param config configuration properties * @param componentRepository repository for shared components */ private JPanel initButtonPannel(SwingConfig config, ComponentRepository componentRepository) { JPanel buttonPannel = new JPanel(); buttonPannel.setAlignmentX(Component.LEFT_ALIGNMENT); buttonPannel.setLayout(new FlowLayout(FlowLayout.TRAILING)); // FIND if (operationType == OperationType.FIND) { JButton findButton = new JButton(localizer.localize("button.find")); componentRepository.getOperationCallBackListener().addComponentStartDisabled(findButton, OperationType.FIND); componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(findButton, OperationType.FIND); findButton.addActionListener(componentRepository.getFindCommand()); findButton.addActionListener(new ReorderFilePatternListListener(componentRepository.getFindForm(), config.getFileNamePatternListModel())); buttonPannel.add(findButton); } // REPLACE if (operationType == OperationType.REPLACE) { JButton replaceButton = new JButton(localizer.localize("button.replace")); replaceButton.setEnabled(false); componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(replaceButton, OperationType.FIND); componentRepository.getResetDispatcher().addToBeDisabled(replaceButton); componentRepository.getSearchBaseListener().addToBeDisabled(replaceButton); ConfirmReplaceListener replaceListener = new ConfirmReplaceListener(componentRepository.getRootWindow(), config, componentRepository.getReplaceForm()); replaceListener.addActionListener(componentRepository.getReplaceCommand()); replaceButton.addActionListener(replaceListener); buttonPannel.add(replaceButton); } // RENAME if (operationType == OperationType.RENAME) { JButton renameButton = new JButton(componentRepository.getRenameCommand()); renameButton.setEnabled(false); componentRepository.getResetDispatcher().addToBeDisabled(renameButton); buttonPannel.add(renameButton); } // CANCEL JButton cancelButton = new JButton(localizer.localize("button.cancel")); cancelButton.setEnabled(false); componentRepository.getOperationCallBackListener().addComponentStartEnabled(cancelButton, OperationType.ANY); cancelButton.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent event) { backend.abort(); } }); buttonPannel.add(cancelButton); componentRepository.getResetDispatcher().addToBeDisabled(cancelButton); // UNDO if (operationType == OperationType.REPLACE) { JButton undoButton = new JButton(localizer.localize("button.undo")); undoButton.setEnabled(false); componentRepository.getOperationCallBackListener().addComponentTerminationEnabled(undoButton, OperationType.REPLACE); componentRepository.getOperationCallBackListener().addComponentStartDisabled(undoButton, OperationType.FIND); undoButton.addActionListener(componentRepository.getUndoListener()); undoButton.addActionListener(new OnClickDisable(undoButton)); buttonPannel.add(undoButton); } // RESET JButton clearButton = new JButton(localizer.localize("button.reset")); clearButton.addActionListener(componentRepository.getResetDispatcher()); buttonPannel.add(clearButton); // this.add( buttonPannel ); return buttonPannel; }
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
private void onStopDiscoveryPre(JButton stopStartButton) { stopStartButton.setEnabled(false); }
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
private void onStartDiscoveryPre(JButton stopStartButton) { stopStartButton.setEnabled(false); depthComboBox.setEditable(false);/*ww w .j a va 2s .co m*/ addressTextField.setEditable(false); }
From source file:Main.java
public Main() { super(new BorderLayout()); listModel.addElement("A"); listModel.addElement("B"); listModel.addElement("C"); list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);/* w ww . j av a2s . c o m*/ list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(addCommand); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(addCommand); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); fireButton = new JButton(deleteCommand); fireButton.setActionCommand(deleteCommand); fireButton.addActionListener(new FireListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); System.out.println(name); // Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }
From source file:es.emergya.ui.gis.popups.GPSDialog.java
@Override public void actionPerformed(ActionEvent e) { if (e.getActionCommand().equals(i18n.getString("window.gps.button.actualizar"))) { last_bandejaSalida = send();/*w ww . jav a 2 s . c o m*/ log.info("bandeja de salida: " + last_bandejaSalida); if (last_bandejaSalida == null) { return; } final JButton request = ((JButton) e.getSource()); request.setEnabled(false); progressIcon.setIcon(iconEnviando); notification.setForeground(Color.WHITE); SolicitudGPSActionListener listener = new SolicitudGPSActionListener(last_bandejaSalida); Timer t = new Timer(1000, listener); listener.setTimer(t); t.start(); } if (e.getActionCommand().equals(i18n.getString("Buttons.cancel"))) { if (last_bandejaSalida != null) { MessageGenerator.remove(last_bandejaSalida.getId()); } last_bandejaSalida = null; dispose(); } }
From source file:com.willwinder.universalgcodesender.uielements.macros.MacroActionPanel.java
@Override public void doLayout() { Settings s = backend.getSettings();/*from w ww . j av a 2 s. co m*/ // Lookup macros. if (macrosDirty) { Integer lastMacroIndex = s.getLastMacroIndex() + 1; macros.clear(); for (int i = 0; i < lastMacroIndex; i++) { Macro m = s.getMacro(i); if (StringUtils.isNotEmpty(m.getGcode())) { macros.add(s.getMacro(i)); } } } // Cache the largest width amongst the buttons. int maxWidth = 0; int maxHeight = 0; // Create buttons. for (int i = 0; i < macros.size(); i++) { final int index = i; Macro macro = macros.get(i); JButton button; if (customGcodeButtons.size() <= i) { button = new JButton(i + ""); button.setEnabled(false); customGcodeButtons.add(button); // Add action listener button.addActionListener((ActionEvent evt) -> { customGcodeButtonActionPerformed(index); }); } else { button = customGcodeButtons.get(i); } if (!StringUtils.isEmpty(macro.getName())) { button.setText(macro.getName()); } else if (!StringUtils.isEmpty(macro.getDescription())) { button.setText(macro.getDescription()); } if (!StringUtils.isEmpty(macro.getDescription())) { button.setToolTipText(macro.getDescription()); } if (button.getPreferredSize().width > maxWidth) maxWidth = button.getPreferredSize().width; if (button.getPreferredSize().height > maxHeight) maxHeight = button.getPreferredSize().height; } // If button count was reduced, clear out any extras. if (customGcodeButtons.size() > macros.size()) { this.macroPanel.removeAll(); this.macroPanel.repaint(); for (int i = customGcodeButtons.size(); i > macros.size(); i--) { JButton b = customGcodeButtons.remove(i - 1); } } // Calculate columns/rows which can fit in the space we have. int columns = (getWidth() - (2 * INSET)) / (maxWidth + PADDING); int rows = (getHeight() - (2 * INSET)) / (maxHeight + PADDING); // At least one column. columns = Math.max(columns, 1); // Update number of rows if more are needed. if (columns * rows < customGcodeButtons.size()) { rows = customGcodeButtons.size() / columns; if (customGcodeButtons.size() % columns != 0) rows++; } // Layout for buttons. StringBuilder columnConstraint = new StringBuilder(); for (int i = 0; i < columns; i++) { if (i > 0) { columnConstraint.append("unrelated"); } columnConstraint.append("[fill, sg 1]"); } MigLayout layout = new MigLayout("fillx, wrap " + columns + ", inset " + INSET, columnConstraint.toString()); macroPanel.setLayout(layout); // Put buttons in grid. int x = 0; int y = 0; for (JButton button : customGcodeButtons) { macroPanel.add(button, "cell " + x + " " + y); y++; if (y == rows) { x++; y = 0; } } super.doLayout(); }
From source file:SimpleSoundCapture.java
private JButton addButton(String name, JPanel p, boolean state) { JButton b = new JButton(name); b.addActionListener(this); b.setEnabled(state); p.add(b);/*from w w w. jav a2s .co m*/ return b; }
From source file:net.itransformers.topologyviewer.dialogs.snmpDiscovery.DiscoveryManagerDialogV2.java
private void onStartDiscoveryPost(JButton stopStartButton) { stopStartButton.setText("Stop"); pauseResumeButton.setEnabled(true);/*ww w.jav a 2 s . co m*/ stopStartButton.setEnabled(true); }
From source file:components.ListDemo.java
public ListDemo() { super(new BorderLayout()); listModel = new DefaultListModel(); listModel.addElement("Jane Doe"); listModel.addElement("John Smith"); listModel.addElement("Kathy Green"); //Create the list and put it in a scroll pane. list = new JList(listModel); list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); list.setSelectedIndex(0);/* w w w . jav a2 s. c om*/ list.addListSelectionListener(this); list.setVisibleRowCount(5); JScrollPane listScrollPane = new JScrollPane(list); JButton hireButton = new JButton(hireString); HireListener hireListener = new HireListener(hireButton); hireButton.setActionCommand(hireString); hireButton.addActionListener(hireListener); hireButton.setEnabled(false); fireButton = new JButton(fireString); fireButton.setActionCommand(fireString); fireButton.addActionListener(new FireListener()); employeeName = new JTextField(10); employeeName.addActionListener(hireListener); employeeName.getDocument().addDocumentListener(hireListener); String name = listModel.getElementAt(list.getSelectedIndex()).toString(); //Create a panel that uses BoxLayout. JPanel buttonPane = new JPanel(); buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.LINE_AXIS)); buttonPane.add(fireButton); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(new JSeparator(SwingConstants.VERTICAL)); buttonPane.add(Box.createHorizontalStrut(5)); buttonPane.add(employeeName); buttonPane.add(hireButton); buttonPane.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5)); add(listScrollPane, BorderLayout.CENTER); add(buttonPane, BorderLayout.PAGE_END); }