Java Code Examples for javax.swing.AbstractButton#setEnabled()
The following examples show how to use
javax.swing.AbstractButton#setEnabled() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractToolbarFactory.java From netbeans with Apache License 2.0 | 6 votes |
private void configureToolbarButton (AbstractButton item, String containerCtx, String action, ActionProvider provider, Map ctx) { item.setFocusable(false); item.setName(action); item.putClientProperty (KEY_ACTION, action); item.setToolTipText( provider.getDisplayName(action, containerCtx)); // item.setToolTipText(provider.getDescription(action, containerCtx)); int state = ctx == null ? ActionProvider.STATE_VISIBLE : provider.getState (action, containerCtx, ctx); boolean enabled = (state & ActionProvider.STATE_ENABLED) != 0; item.setEnabled(enabled); boolean visible = (state & ActionProvider.STATE_VISIBLE) != 0; item.setVisible (visible); boolean toggled = (state & ActionProvider.STATE_SELECTED) != 0; item.setSelected(toggled); // item.setMnemonic(provider.getMnemonic(action, containerCtx)); // item.setDisplayedMnemonicIndex(provider.getMnemonicIndex(action, containerCtx)); item.setIcon(provider.getIcon(action, containerCtx, BeanInfo.ICON_COLOR_16x16)); }
Example 2
Source File: PixelExtractionDialog.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override protected void done() { try { get(); Object outputDir = parameterMap.get("outputDir"); String message; if (outputDir != null) { message = String.format( "The pixel extraction tool has run successfully and written the result file(s) to %s.", outputDir.toString()); } else { message = "The pixel extraction tool has run successfully and written the result file to to std.out."; } showInformationDialog(message); } catch (InterruptedException ignore) { } catch (ExecutionException e) { appContext.handleError(e.getMessage(), e); } finally { AbstractButton runButton = getButton(ID_OK); runButton.setEnabled(true); } }
Example 3
Source File: SingleTargetProductDialog.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private void updateRunButton() { AbstractButton button = getButton(ID_APPLY); boolean save = targetProductSelector.getModel().isSaveToFileSelected(); boolean open = targetProductSelector.getModel().isOpenInAppSelected(); String toolTipText = ""; boolean enabled = true; if (save && open) { toolTipText = "Save target product and open it in " + getAppContext().getApplicationName(); } else if (save) { toolTipText = "Save target product"; } else if (open) { toolTipText = "Open target product in " + getAppContext().getApplicationName(); } else { enabled = false; } button.setToolTipText(toolTipText); button.setEnabled(enabled); }
Example 4
Source File: StatisticsPanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
private AbstractButton getExportButton() { final AbstractButton export = ToolButtonFactory.createButton(UIUtils.loadImageIcon("icons/Export24.gif"), false); export.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent e) { JPopupMenu viewPopup = new JPopupMenu("Export"); viewPopup.add(exportAsCsvAction); viewPopup.add(putStatisticsIntoVectorDataAction); final Rectangle buttonBounds = export.getBounds(); viewPopup.show(export, 1, buttonBounds.height + 1); } }); export.setEnabled(false); return export; }
Example 5
Source File: TableViewPagePanel.java From snap-desktop with GNU General Public License v3.0 | 6 votes |
@Override protected void initComponents() { final AbstractButton switchToChartButton = ToolButtonFactory.createButton(iconForSwitchToChartButton, false); switchToChartButton.setToolTipText("Switch to Chart View"); switchToChartButton.setName("switchToChartButton"); switchToChartButton.setEnabled(hasAlternativeView()); switchToChartButton.addActionListener(e -> showAlternativeView()); final JPanel buttonPanel = new JPanel(new BorderLayout()); buttonPanel.add(switchToChartButton, BorderLayout.NORTH); buttonPanel.add(getHelpButton(), BorderLayout.SOUTH); add(buttonPanel, BorderLayout.EAST); table = new JTable(); table.removeEditor(); table.setGridColor(Color.LIGHT_GRAY.brighter()); table.addMouseListener(new PagePanel.PopupHandler()); table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); final JScrollPane scrollPane = new JScrollPane(table); add(scrollPane, BorderLayout.CENTER); }
Example 6
Source File: PixelExtractionDialog.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
@Override protected Void doInBackground(ProgressMonitor pm) throws Exception { pm.beginTask("Computing pixel values...", -1); AbstractButton runButton = getButton(ID_OK); runButton.setEnabled(false); try { GPF.createProduct("PixEx", parameterMap, ioForm.getSourceProducts()); pm.worked(1); } finally { pm.done(); } return null; }
Example 7
Source File: ChartPagePanel.java From snap-desktop with GNU General Public License v3.0 | 5 votes |
private JPanel createTopPanel() { refreshButton = ToolButtonFactory.createButton( UIUtils.loadImageIcon("icons/ViewRefresh22.png"), false); refreshButton.setToolTipText("Refresh View"); refreshButton.setName("refreshButton"); refreshButton.addActionListener(e -> { updateChartData(); refreshButton.setEnabled(false); }); AbstractButton switchToTableButton = ToolButtonFactory.createButton( UIUtils.loadImageIcon("icons/Table24.png"), false); switchToTableButton.setToolTipText("Switch to Table View"); switchToTableButton.setName("switchToTableButton"); switchToTableButton.setEnabled(hasAlternativeView()); switchToTableButton.addActionListener(e -> showAlternativeView()); final TableLayout tableLayout = new TableLayout(6); tableLayout.setColumnFill(2, TableLayout.Fill.HORIZONTAL); tableLayout.setColumnWeightX(2, 1.0); tableLayout.setRowPadding(0, new Insets(0, 4, 0, 0)); JPanel buttonPanel = new JPanel(tableLayout); buttonPanel.add(refreshButton); tableLayout.setRowPadding(0, new Insets(0, 0, 0, 0)); buttonPanel.add(switchToTableButton); buttonPanel.add(new JPanel()); return buttonPanel; }
Example 8
Source File: Form.java From javamoney-examples with Apache License 2.0 | 5 votes |
/** * This method enables or disables the elements of the from depending of the * specified value. * * @param value true or false. */ protected void enableForm(boolean value) { // Enable buttons. for(AbstractButton button : getButtons()) { button.setEnabled(value); } // Enable fields. for(JTextField field : getFields()) { field.setEnabled(value); } // Enable choosers. getPayToChooser().setEnabled(value); getPayFromChooser().setEnabled(value); // Set defaults. getButton(NEW).setEnabled(true); // Splits are only for non-transfers. if(value == true && getType() == TRANSFER) { getButton(SPLIT).setEnabled(false); } }