javax.swing.AbstractButton#isSelected ( )源码实例Demo

下面列出了javax.swing.AbstractButton#isSelected ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: netbeans   文件: ProfilerPopup.java
public Component getDefaultComponent(Container aContainer) {
    Component c = getFirstComponent(aContainer);
    
    if (c instanceof AbstractButton) {
        ButtonModel bm = ((AbstractButton)c).getModel();
        if (bm instanceof DefaultButtonModel) {
            ButtonGroup bg = ((DefaultButtonModel)bm).getGroup();
            Enumeration<AbstractButton> en = bg == null ? null : bg.getElements();
            while (en != null && en.hasMoreElements()) {
                AbstractButton ab = en.nextElement();
                if (ab.isSelected()) return ab;
            }
        }
    }
    
    return c;
}
 
源代码2 项目: osp   文件: FunctionEditor.java
/**
 * Gets an undoable edit.
 *
 * @param type may be ADD_EDIT, REMOVE_EDIT, NAME_EDIT, or EXPRESSION_EDIT 
 * @param redo the new state
 * @param redoRow the newly selected row
 * @param redoCol the newly selected column
 * @param undo the previous state
 * @param undoRow the previously selected row
 * @param undoCol the previously selected column
 * @param name the name of the edited object
 */
protected UndoableEdit getUndoableEdit(int type, Object redo, int redoRow, int redoCol, Object undo, int undoRow, int undoCol, String name) {
  if(type==EXPRESSION_EDIT) {
    ArrayList<AbstractButton> selectedButtons = new ArrayList<AbstractButton>();
    undo = new Object[] {undo, selectedButtons};
    redo = new Object[] {redo, selectedButtons};
    if(customButtons!=null) {
      for(AbstractButton b : customButtons) {
        if(b.isSelected()) {
          selectedButtons.add(b);
        }
      }
    }
  }
  return new DefaultEdit(type, redo, redoRow, redoCol, undo, undoRow, undoCol, name);
}
 
源代码3 项目: MikuMikuStudio   文件: ToggleButtonGroup.java
public void add(AbstractButton b) {
    if (b == null) {
        return;
    }
    buttons.addElement(b);

    if (b.isSelected()) {
        if (modifiedSelection == null) {
            modifiedSelection = b.getModel();
        } else {
            b.setSelected(false);
        }
    }

    b.getModel().setGroup(this);
}
 
@Override
public void actionPerformed(final ActionEvent e) {
  synchronized (panel) {
    final AbstractButton button = (AbstractButton) ((OptionElement) panel).findFirstWithName("/" + BTN_NAME).getUIComponent();
    final boolean selected = button.isSelected();
    panel.setShowMasterSlaveRelationShip(selected);
    setupNameAndTooltip(BTN_NAME + "." + (selected ? "on" : "off"));
  }
}
 
源代码5 项目: JPPF   文件: ToggleLayoutAction.java
/**
 * {@inheritDoc}
 */
@Override
public void actionPerformed(final ActionEvent e) {
  synchronized (panel) {
    final AbstractButton button = (AbstractButton) panel.findFirstWithName("/graph.toggle.layout").getUIComponent();
    final boolean selected = button.isSelected();
    panel.setAutoLayout(selected);
    setupNameAndTooltip("graph.toggle.layout." + (selected ? "on" : "off"));
  }
}
 
源代码6 项目: jpexs-decompiler   文件: MainFrameMenu.java
protected void disableDecompilationActionPerformed(ActionEvent evt) {
    AbstractButton button = (AbstractButton) evt.getSource();
    boolean selected = button.isSelected();

    Configuration.decompile.set(!selected);
    mainFrame.getPanel().disableDecompilationChanged();
}
 
源代码7 项目: snap-desktop   文件: TimeSeriesExportHelper.java
private static int parseLevel(ButtonGroup buttonGroup) {
    Enumeration<AbstractButton> buttonEnumeration = buttonGroup.getElements();
    while (buttonEnumeration.hasMoreElements()) {
        AbstractButton abstractButton = buttonEnumeration.nextElement();
        if (abstractButton.isSelected()) {
            String buttonText = abstractButton.getText();
            final int index = buttonText.indexOf(" (");
            if (index != -1) {
                buttonText = buttonText.substring(0, index);
            }
            return Integer.parseInt(buttonText);
        }
    }
    return-1;
}
 
源代码8 项目: netbeans   文件: NbEditorToolBar.java
private static void removeButtonContentAreaAndBorder(AbstractButton button) {
    boolean canRemove = true;
    if (button instanceof JToggleButton) {
        canRemove = !button.isSelected();
    }
    if (canRemove) {
        button.setContentAreaFilled(false);
        button.setBorderPainted(false);
    }
}
 
private String getSelectedButton(ButtonGroup bGroup) {
    for (Enumeration<AbstractButton> buttons = bGroup.getElements(); buttons.hasMoreElements();) {
        AbstractButton button = buttons.nextElement();
        if (button.isSelected()) {
            return button.getText();
        }
    }
    return "None";
}
 
源代码10 项目: jpexs-decompiler   文件: MainFrameMenu.java
protected void setSubLimiter(ActionEvent evt) {
    if (Main.isWorking()) {
        return;
    }

    AbstractButton button = (AbstractButton) evt.getSource();
    boolean selected = button.isSelected();
    Main.setSubLimiter(selected);
}
 
源代码11 项目: jpexs-decompiler   文件: MainFrameMenu.java
protected void autoDeobfuscationActionPerformed(ActionEvent evt) {
    AbstractButton button = (AbstractButton) evt.getSource();
    boolean selected = button.isSelected();

    if (View.showConfirmDialog(mainFrame.getPanel(), translate("message.confirm.autodeobfuscate") + "\r\n" + (selected ? translate("message.confirm.on") : translate("message.confirm.off")), translate("message.confirm"), JOptionPane.OK_CANCEL_OPTION) == JOptionPane.OK_OPTION) {
        Configuration.autoDeobfuscate.set(selected);
        mainFrame.getPanel().autoDeobfuscateChanged();
    } else {
        button.setSelected(Configuration.autoDeobfuscate.get());
    }
}
 
源代码12 项目: visualvm   文件: TransparentToolBar.java
private void refresh(final AbstractButton b) {
    b.setBackground(UISupport.getDefaultBackground());
    boolean hovered = Boolean.TRUE.equals(b.getClientProperty(PROP_HOVERED));
    boolean filled = b.isEnabled() && (hovered || b.isSelected() || b.isFocusOwner());
    b.setOpaque(filled);
    b.setContentAreaFilled(filled);
    b.repaint();
}
 
源代码13 项目: beautyeye   文件: DemoSelectorPanel.java
public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    AbstractButton b = (AbstractButton)c;
    if (b.isSelected()) {
        Color color = c.getBackground();
        g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.20f));
        g.drawLine(x, y, x + width, y);
        g.setColor(Utilities.deriveColorHSB(color, 0, 0, -.10f));
        g.drawLine(x, y + 1, x + width, y + 1);
        g.drawLine(x, y + 2, x, y + height - 2);
        g.setColor(Utilities.deriveColorHSB(color, 0, 0, .24f));
        g.drawLine(x, y + height - 1, x + width, y + height-1);
    }
}
 
源代码14 项目: JavaMainRepo   文件: AddFrame.java
public String getSelectedRadioButton() {
	for (Enumeration<AbstractButton> allButtons = buttonGroup.getElements(); allButtons.hasMoreElements();) {
		AbstractButton button = allButtons.nextElement();
		if (button.isSelected()) {
			return button.getText();
		}
	}
	return null;
}
 
源代码15 项目: snap-desktop   文件: ToolButtonFactory.java
private void setDefaultState(AbstractButton b) {
    if (b.isSelected()) {
        setSelectedState(b);
    } else {
        setNormalState(b);
    }
}
 
源代码16 项目: jpexs-decompiler   文件: MainFrameMenu.java
protected void simplifyExpressionsActionPerformed(ActionEvent evt) {
    AbstractButton button = (AbstractButton) evt.getSource();
    boolean selected = button.isSelected();

    Configuration.simplifyExpressions.set(selected);
    mainFrame.getPanel().autoDeobfuscateChanged();
}
 
源代码17 项目: pumpernickel   文件: BoxTabbedPaneUI.java
protected void refreshTabStates() {
	List<Component> newTabs = new ArrayList<>();
	for (int a = 0; a < tabs.getTabCount(); a++) {
		JComponent tab = (JComponent) tabs.getTabComponentAt(a);
		if (tab == null)
			tab = getDefaultTab(a);

		TabContainer tabContainer = (TabContainer) tab
				.getClientProperty(PROPERTY_TAB_CONTAINER);
		if (tabContainer == null) {
			tabContainer = new TabContainer(tabs, a, tab);
			tab.putClientProperty(PROPERTY_TAB_CONTAINER, tabContainer);
		}

		newTabs.add(tabContainer);
		tab.putClientProperty(PROPERTY_TAB_INDEX, a);
		getStyle(tabs).formatControlRowButton(tabs, tabContainer, a);
	}

	Boolean hideSingleTab = (Boolean) tabs
			.getClientProperty(PROPERTY_HIDE_SINGLE_TAB);
	if (hideSingleTab == null)
		hideSingleTab = Boolean.FALSE;
	controlRow.setVisible(!(tabs.getTabCount() <= 1 && hideSingleTab));

	if (!(tabsContainer.getLayout() instanceof SplayedLayout)) {
		SplayedLayout l = new SplayedLayout(true) {

			@Override
			protected Collection<JComponent> getEmphasizedComponents(
					JComponent container) {
				Collection<JComponent> returnValue = super
						.getEmphasizedComponents(container);

				for (Component c : container.getComponents()) {
					if (c instanceof AbstractButton) {
						AbstractButton ab = (AbstractButton) c;
						if (ab.isSelected())
							returnValue.add(ab);
					}
				}
				return returnValue;
			}

		};
		tabsContainer.setLayout(l);
	}
	int orientation = tabs.getTabPlacement() == SwingConstants.LEFT
			|| tabs.getTabPlacement() == SwingConstants.RIGHT ? SwingConstants.VERTICAL
			: SwingConstants.HORIZONTAL;
	((SplayedLayout) tabsContainer.getLayout()).setOrientation(null,
			orientation);

	setComponents(tabsContainer, newTabs);

	tabsContainer.revalidate();
}
 
源代码18 项目: jpexs-decompiler   文件: MainFrameMenu.java
protected void autoOpenLoadedSWFsActionPerformed(ActionEvent evt) {
    AbstractButton button = (AbstractButton) evt.getSource();
    boolean selected = button.isSelected();

    Configuration.autoOpenLoadedSWFs.set(selected);
}
 
源代码19 项目: swift-explorer   文件: MainPanel.java
protected void onUploadDirectory() 
 {
 	List<StoredObject> sltObj = getSelectedStoredObjects() ;
 	if (sltObj != null && sltObj.size() > 1)
 		return ; // should never happen, because in such a case the menu is disable
 	StoredObject parentObject = (sltObj == null || sltObj.isEmpty()) ? (null) : (sltObj.get(0)) ;
 	
     final Container container = getSelectedContainer();
     final JFileChooser chooser = new JFileChooser();
     chooser.setMultiSelectionEnabled(false);
     chooser.setCurrentDirectory(lastFolder);
     chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY);
     
     final JPanel optionPanel = getOptionPanel ();
     chooser.setAccessory(optionPanel);
     AbstractButton overwriteCheck = setOverwriteOption (optionPanel) ;
     
     if (chooser.showOpenDialog(this) == JFileChooser.APPROVE_OPTION) 
     {
         final File selectedDir = chooser.getSelectedFile();
         try 
         {
         	boolean overwriteAll = overwriteCheck.isSelected() ;
         	if (overwriteAll)
         	{
         		if (!confirm(getLocalizedString("confirm_overwrite_any_existing_files")))
         			return ;
         	}
	ops.uploadDirectory(container, parentObject, selectedDir, overwriteAll, getNewSwiftStopRequester (), callback);
	
	// We open the progress window, for it is likely that this operation
	// will take a while
          //onProgressButton () ;
} 
         catch (IOException e) 
{
	logger.error("Error occurred while uploading a directory.", e);
}
         lastFolder = chooser.getCurrentDirectory();
     }
 }
 
源代码20 项目: ghidra   文件: AbstractDockingTest.java
/**
 * Ensures that the selected state of the button matches <code>selected</code>.
 * <p>
 * Note: this works for most toggle button implementations which are derived from
 * AbstractButton and relay on {@link AbstractButton#isSelected()} and
 * {@link AbstractButton#doClick()} for toggling, such as:
 * <ul>
 * 	<li>{@link JCheckBox}</li>
 *  <li>{@link JRadioButton}</li>
 *  <li>{@link EmptyBorderToggleButton}</li>
 * </ul>
 * @param button the button to select
 * @param selected true to toggle the button to selected; false for de-selected
 */
public static void setToggleButtonSelected(AbstractButton button, boolean selected) {
	boolean isSelected = button.isSelected();
	if (isSelected != selected) {
		pressButton(button);
	}
}