Java Code Examples for javax.swing.JButton#setSelected()
The following examples show how to use
javax.swing.JButton#setSelected() .
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: JButtonBuilder.java From triplea with GNU General Public License v3.0 | 6 votes |
/** * Constructs a Swing JButton using current builder values. Values that must be set: title, * actionlistener */ public JButton build() { checkNotNull(title); final JButton button = new JButton(title); Optional.ofNullable(clickAction) .ifPresent(listener -> button.addActionListener(e -> clickAction.accept(button))); Optional.ofNullable(toolTip).ifPresent(button::setToolTipText); button.setSelected(selected); button.setEnabled(enabled); if (biggerFont > 0) { button.setFont( new Font( button.getFont().getName(), button.getFont().getStyle(), button.getFont().getSize() + biggerFont)); } return button; }
Example 2
Source File: JTSTestBuilderToolBar.java From jts with GNU Lesser General Public License v2.1 | 6 votes |
private JButton createButton(String toolTipText, ImageIcon icon, java.awt.event.ActionListener actionListener) { JButton btn = new JButton(); btn.setMargin(new Insets(0, 0, 0, 0)); btn.setPreferredSize(new Dimension(30, 30)); btn.setIcon(icon); btn.setMinimumSize(new Dimension(30, 30)); btn.setVerticalTextPosition(SwingConstants.BOTTOM); btn.setSelected(false); btn.setToolTipText(toolTipText); btn.setHorizontalTextPosition(SwingConstants.CENTER); btn.setFont(new java.awt.Font("SansSerif", 0, 10)); btn.setMaximumSize(new Dimension(30, 30)); btn.addActionListener(actionListener); return btn; }
Example 3
Source File: PresenterUpdater.java From netbeans with Apache License 2.0 | 5 votes |
private PresenterUpdater(int type, Action action) { if (action == null) { throw new IllegalArgumentException("action must not be null"); // NOI18N } this.type = type; this.actionName = (String) action.getValue(Action.NAME); this.action = action; if (type == TOOLBAR) { presenter = new JButton(); useActionSelectedProperty = false; } else { // MENU or POPUP useActionSelectedProperty = (action.getValue(AbstractEditorAction.PREFERENCES_KEY_KEY) != null); if (useActionSelectedProperty) { presenter = new LazyJCheckBoxMenuItem(); presenter.setSelected(isActionSelected()); } else { presenter = new LazyJMenuItem(); } } action.addPropertyChangeListener(WeakListeners.propertyChange(this, action)); if (type == MENU) { listenedContextActions = new WeakSet<Action>(); EditorRegistryWatcher.get().registerPresenterUpdater(this); // Includes notification of active component } else { listenedContextActions = null; } presenter.addActionListener(this); updatePresenter(null); // Not active yet => mark updates pending }
Example 4
Source File: ProgramPanel.java From mpcmaid with GNU Lesser General Public License v2.1 | 3 votes |
private void selectPad(final Pad selectedPad, final int padId, final JButton button) { final JButton lastSelected = padButtons[selectedPad.getElementIndex()]; lastSelected.setSelected(false); selectedPad.setElementIndex(padId); currentlySelectedPad = selectedPad;// remember currently selected pad button.setSelected(true); // System.out.println("Pad " + padId + " pressed!"); refreshParamsArea(); }