当前位置: 首页>>代码示例>>Java>>正文


Java AbstractButton.setSelected方法代码示例

本文整理汇总了Java中javax.swing.AbstractButton.setSelected方法的典型用法代码示例。如果您正苦于以下问题:Java AbstractButton.setSelected方法的具体用法?Java AbstractButton.setSelected怎么用?Java AbstractButton.setSelected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.AbstractButton的用法示例。


在下文中一共展示了AbstractButton.setSelected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setOption

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Set value of a search pattern option. Bound abstract button will be
 * selected or deselected accordingly.
 */
private void setOption(@NonNull Option option, boolean value) {
    Parameters.notNull("option", option);                           //NOI18N
    options.put(option, value);
    AbstractButton button = bindings.get(option);
    if (button != null) {
        button.setSelected(value);
    }
    if (option == Option.REGULAR_EXPRESSION) {
        if ((matchType == MatchType.REGEXP) != value) {
            setMatchType(value ? MatchType.REGEXP : MatchType.LITERAL);
        }
        updateValidity();
    }
    fireChange();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:SearchPatternController.java

示例2: configureToolbarButton

import javax.swing.AbstractButton; //导入方法依赖的package包/类
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));
    }
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractToolbarFactory.java

示例3: setSelected

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Selects the given action in the menu. This methods also updates the selection status of the
 * toggle button.
 *
 * @param action
 *            the action which should be selected
 */
public void setSelected(Action action) {
	Enumeration<AbstractButton> menuEnum = popupMenuGroup.getElements();
	boolean found = false;
	while (menuEnum.hasMoreElements()) {
		AbstractButton button = menuEnum.nextElement();
		if (action == button.getAction()) {
			button.setSelected(true);
			found = true;
		} else {
			button.setSelected(false);
		}
	}
	if (found) {
		setFont(getFont().deriveFont(Font.BOLD));
		updateSelectionStatus();
	} else {
		setFont(getFont().deriveFont(Font.PLAIN));
		clearMenuSelection();
	}
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:28,代码来源:CompositeMenuToggleButton.java

示例4: selectABrowser

import javax.swing.AbstractButton; //导入方法依赖的package包/类
private void selectABrowser() {
    String browser = getPreviouslySelectedBrowser();
    if (browser == null) {
        browser = RunManager.getGlobalSettings().getBrowser();
    }
    if (browser != null) {
        for (Enumeration<AbstractButton> buttons = browserSelectButtonGroup.getElements(); buttons.hasMoreElements();) {
            AbstractButton button = buttons.nextElement();
            if (button.getActionCommand().equals(browser)) {
                button.setSelected(true);
            }
        }
    } else {
        browserSelectButtonGroup.setSelected(browserSelectButtonGroup.getElements().nextElement().getModel(), true);
    }
}
 
开发者ID:CognizantQAHub,项目名称:Cognizant-Intelligent-Test-Scripter,代码行数:17,代码来源:TestCaseToolBar.java

示例5: event

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public void event(MT type, Object data)
{
	switch (type)
	{
        case SERIES_CHANGED:
            boolean blank = ((data == null) || (data.equals("<none>")));
               edit.setEnabled(!blank);
               event.setEnabled(!blank);
               results.setEnabled(!blank);
               break;

		case EVENT_CHANGED:
			/* when we first start or the a new event is selected, will also double when selecting via menu */
			Enumeration<AbstractButton> e = runGrouping.getElements();
			while (e.hasMoreElements())
			{
				AbstractButton b = e.nextElement();
				int run = Integer.parseInt(b.getActionCommand().split(" ")[0]);
				if (run == DataEntry.state.getCurrentEvent().getRuns())
					b.setSelected(true);
			}
		    break;
	}
}
 
开发者ID:drytoastman,项目名称:scorekeeperfrontend,代码行数:26,代码来源:Menus.java

示例6: bind

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Bind an abstract button (usually checkbox) to a SearchPattern option.
 *
 * @param option Option whose value the button should represent.
 * @param button Button to control and display the option.
 */
public void bind(@NonNull final Option option,
        @NonNull final AbstractButton button) {
    Parameters.notNull("option", option);                           //NOI18N
    Parameters.notNull("button", button);                           //NOI18N

    if (bindings.containsKey(option)) {
        throw new IllegalStateException(
                "Already binded with option " + option);           // NOI18N
    }

    bindings.put(option, button);
    button.setSelected(getOption(option));
    button.addItemListener(new ItemListener() {
        @Override
        public void itemStateChanged(ItemEvent e) {
            setOption(option, button.isSelected());
        }
    });
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:26,代码来源:SearchPatternController.java

示例7: updateButton

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/** Updates the state of those pushbuttons in the left
 * vertical tool box that need to indicate the special "ambiguous"
 * state marking that some of the currently selected components
 * have the respective property set while some do not.
 */
private void updateButton(AbstractButton button, boolean nonEmptySelection, boolean allSelectedUnambiguous, String iconWarning, String toolTipWarning, String iconNormal, String toolTipNormal) {
    button.setSelected(allSelectedUnambiguous);
    if(nonEmptySelection && !allSelectedUnambiguous) {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconWarning, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipWarning)); // NOI18N
    } else {
        button.setIcon(ImageUtilities.loadImageIcon("org/netbeans/modules/form/layoutsupport/griddesigner/resources/" + iconNormal, false)); // NOI18N
        button.setToolTipText(NbBundle.getMessage(GridBagCustomizer.class, "GridBagCustomizer." + toolTipNormal)); // NOI18N
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:16,代码来源:GridBagCustomizer.java

示例8: updateButton

import javax.swing.AbstractButton; //导入方法依赖的package包/类
static final void updateButton(AbstractButton btnResume) {
    if (isSuspended()) {
        int pending = Integer.getInteger("org.netbeans.io.pending", 0); // NOI18N
        btnResume.setText(Bundle.MSG_Resume(pending));
        btnResume.setSelected(true);
    } else {
        btnResume.setText(null);
        btnResume.setSelected(false);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:PauseAction.java

示例9: getToolbarPresenter

import javax.swing.AbstractButton; //导入方法依赖的package包/类
public AbstractButton getToolbarPresenter() {
    if(toolbarItems == null) {
        toolbarItems = new WeakSet<AbstractButton>(4);
    }
    AbstractButton b = new DefaultIconToggleButton();
    toolbarItems.add(b);
    b.setSelected(isPreferencesSelected());
    Actions.connect(b, this);
    return b;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:AlwaysEnabledAction.java

示例10: updateItemsSelected

import javax.swing.AbstractButton; //导入方法依赖的package包/类
private void updateItemsSelected() {
    boolean selected = isPreferencesSelected();
    if (menuItem != null) {
        menuItem.setSelected(selected);
    }
    if (popupItem != null) {
        popupItem.setSelected(selected);
    }
    if (toolbarItems != null) {
        for(AbstractButton b : toolbarItems) {
            b.setSelected(selected);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:AlwaysEnabledAction.java

示例11: mouseExited

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public void mouseExited(MouseEvent e) {
	super.mouseExited(e);
	AbstractButton button = (AbstractButton) e.getSource();
	button.getModel().setRollover(false);
	button.setSelected(false);
}
 
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:ButtonListener.java

示例12: buildMenus

import javax.swing.AbstractButton; //导入方法依赖的package包/类
void buildMenus(AEViewer v) {
//        log.info("building AEViewer sync menus");
        JMenu m = v.getFileMenu();

        ToggleLoggingAction action = new ToggleLoggingAction(v);
        v.getLoggingButton().setAction(action);
        v.getLoggingMenuItem().setAction(action);

        // adds to each AEViewers syncenabled check box menu item the toggleSyncEnabledAction
        AbstractButton b = v.getSyncEnabledCheckBoxMenuItem();
        b.setAction(getToggleSyncEnabledAction());
        syncEnableButtons.add(b);   // we need this stupid list because java 1.5 doesn't have Action property to support togglebuttons selected state (1.6 adds it)
        b.setSelected(isSyncEnabled());

        AbstractButton bbb = v.getPlayerControls().getSyncPlaybackCheckBox(); // TODO dependency, depends on existing player control panel
        syncEnableButtons.add(bbb);
        bbb.setSelected(isSyncEnabled());
        bbb.setAction(getToggleSyncEnabledAction());

        boolean en = true; //viewers.size()>1? true:false;
        for (AbstractButton bb : syncEnableButtons) {
            bb.setEnabled(en);
        }

        syncPlayer.getSupport().addPropertyChangeListener(v.getPlayerControls()); // TODO not very clean way of adding property change support....

//        if(en==false) syncEnableButtons.get(0).setSelected(false); // disable sync if there is only one viewer
    }
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:29,代码来源:JAERViewer.java

示例13: actionPerformed

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent e) {
    log.info("JAERViewer.ToggleSyncEnabledAction.actionPerformed");
    setSyncEnabled(!isSyncEnabled());
    for (AbstractButton b : syncEnableButtons) {
        b.setSelected(isSyncEnabled());
    }
    for (AEViewer v : viewers) {
        AbstractAEPlayer p = isSyncEnabled() ? syncPlayer : v.aePlayer;
        v.getPlayerControls().setAePlayer(p);
    }
}
 
开发者ID:SensorsINI,项目名称:jaer,代码行数:13,代码来源:JAERViewer.java

示例14: setValue

import javax.swing.AbstractButton; //导入方法依赖的package包/类
/**
 * Sets the currently selected button to the button with the given action command.
 *
 * @param group a {@code ButtonGroup}
 * @param value an action command
 */
public static void setValue(final ButtonGroup group, final String value) {
    final AbstractButton targetButton = Collections.list(group.getElements()).stream()
            .filter(button -> button.getActionCommand().equals("\0".equals(value) ? "" : value))
            .findFirst()
            .orElseThrow(() -> new NoSuchElementException("Could not find a button with action command `"
                    + value + "`."));

    targetButton.setSelected(true);
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:16,代码来源:ButtonGroupHelper.java

示例15: testGetValue

import javax.swing.AbstractButton; //导入方法依赖的package包/类
@Test
public void testGetValue() {
    final AbstractButton buttonA = new JButton();
    buttonA.setActionCommand("29zo4");
    final AbstractButton buttonB = new JButton();
    buttonB.setSelected(true);
    buttonB.setActionCommand("Y6ddy");

    group.add(buttonA);
    group.add(buttonB);

    assertThat(ButtonGroupHelper.getValue(group)).isEqualTo("Y6ddy");
}
 
开发者ID:FWDekker,项目名称:intellij-randomness,代码行数:14,代码来源:ButtonGroupHelperTest.java


注:本文中的javax.swing.AbstractButton.setSelected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。