本文整理了Java中javax.swing.JMenuItem.setSelected()
方法的一些代码示例,展示了JMenuItem.setSelected()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JMenuItem.setSelected()
方法的具体详情如下:
包路径:javax.swing.JMenuItem
类名称:JMenuItem
方法名:setSelected
暂无
代码示例来源:origin: chewiebug/GCViewer
@Override
public void internalFrameActivated(InternalFrameEvent e) {
for (int i=2; i < getMenuBar(e).getWindowMenu().getItemCount(); i++) {
final JMenuItem item = getMenuBar(e).getWindowMenu().getItem(i);
if (((WindowMenuItemAction)item.getAction()).getInternalFrame() == e.getInternalFrame()) {
item.setSelected(true);
break;
}
}
getActionMap(e).get(ActionCommands.EXPORT.toString()).setEnabled(true);
getActionMap(e).get(ActionCommands.REFRESH.toString()).setEnabled(true);
getActionMap(e).get(ActionCommands.WATCH.toString()).setEnabled(true);
getActionMap(e).get(ActionCommands.ZOOM.toString()).setEnabled(true);
getActionMap(e).get(ActionCommands.ARRANGE.toString()).setEnabled(true);
// setSelected() does not fire ActionEvent -> both buttons have to be changed
getMenuBar(e).getWatchMenuItem().setSelected(getSelectedGCDocument(e).isWatched());
getToolBar(e).getWatchToggleButton().setSelected(getSelectedGCDocument(e).isWatched());
updateMenuItemState(e);
}
代码示例来源:origin: magefree/mage
@Override
public void mouseClicked(MouseEvent e) {
if (SwingUtilities.isRightMouseButton(e)) {
for (Sort s : sortMenuItems.keySet()) {
sortMenuItems.get(s).setSelected(cardSort == s);
}
hideSelected.setEnabled(!dragCardList().isEmpty());
separateButton.setSelected(separateCreatures);
menu.show(e.getComponent(), e.getX(), e.getY());
}
}
});
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.managerDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.managerDatabase() in "+ this.getClass());
}
for (int i = 0 ; i < MediatorGui.managerDatabase().getMenuStrategy().getItemCount() ; i++) {
MediatorGui.managerDatabase().getMenuStrategy().getItem(i).setEnabled(false);
MediatorGui.managerDatabase().getMenuStrategy().getItem(i).setSelected(false);
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.managerDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.managerDatabase() in "+ this.getClass());
}
MediatorGui.managerDatabase().getMenuStrategy().setText(StrategyInjection.NORMAL.toString());
for (int i = 0 ; i < MediatorGui.managerDatabase().getMenuStrategy().getItemCount() ; i++) {
if (MediatorGui.managerDatabase().getMenuStrategy().getItem(i).getText().equals(StrategyInjection.NORMAL.toString())) {
MediatorGui.managerDatabase().getMenuStrategy().getItem(i).setSelected(true);
break;
}
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.managerDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.managerDatabase() in "+ this.getClass());
}
MediatorGui.managerDatabase().getMenuStrategy().setText(StrategyInjection.TIME.toString());
for (int i = 0 ; i < MediatorGui.managerDatabase().getMenuStrategy().getItemCount() ; i++) {
if (MediatorGui.managerDatabase().getMenuStrategy().getItem(i).getText().equals(StrategyInjection.TIME.toString())) {
MediatorGui.managerDatabase().getMenuStrategy().getItem(i).setSelected(true);
break;
}
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.managerDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.managerDatabase() in "+ this.getClass());
}
MediatorGui.managerDatabase().getMenuStrategy().setText(StrategyInjection.BLIND.toString());
for (int i = 0 ; i < MediatorGui.managerDatabase().getMenuStrategy().getItemCount() ; i++) {
if (MediatorGui.managerDatabase().getMenuStrategy().getItem(i).getText().equals(StrategyInjection.BLIND.toString())) {
MediatorGui.managerDatabase().getMenuStrategy().getItem(i).setSelected(true);
break;
}
}
}
代码示例来源:origin: bobbylight/RSyntaxTextArea
addSyntaxItem("XML", "XMLExample.txt", SYNTAX_STYLE_XML, bg, menu);
addSyntaxItem("YAML", "YamlExample.txt", SYNTAX_STYLE_YAML, bg, menu);
menu.getItem(2).setSelected(true);
mb.add(menu);
代码示例来源:origin: protegeproject/protege
public void setSelected(boolean selected) {
if(menuItem == null) {
return;
}
menuItem.setSelected(selected);
}
代码示例来源:origin: protegeproject/protege
public void setSelected(boolean selected) {
if (menuItem != null) {
menuItem.setSelected(selected);
}
}
代码示例来源:origin: ron190/jsql-injection
@Override
public void execute() {
if (MediatorGui.managerDatabase() == null) {
LOGGER.error("Unexpected unregistered MediatorGui.managerDatabase() in "+ this.getClass());
}
MediatorGui.managerDatabase().getMenuStrategy().setText(StrategyInjection.ERROR.toString());
JMenu menuError = (JMenu) MediatorGui.managerDatabase().getMenuStrategy().getMenuComponent(2);
int indexError = StrategyInjection.ERROR.instance().getIndexMethod();
String nameError = MediatorModel.model().getVendor().instance().getXmlModel().getStrategy().getError().getMethod().get(indexError).getName();
for (int i = 0 ; i < MediatorGui.managerDatabase().getMenuStrategy().getItemCount() ; i++) {
// Fix #44635: ArrayIndexOutOfBoundsException on getItem()
try {
if (menuError.getItem(i).getText().equals(nameError)) {
menuError.getItem(i).setSelected(true);
MediatorGui.managerDatabase().getMenuStrategy().setText(nameError);
break;
}
} catch (ArrayIndexOutOfBoundsException e) {
LOGGER.error(e, e);
}
}
}
代码示例来源:origin: locationtech/jts
JMenuItem createMenuItemSelectable(JMenuItem item, String name, boolean init, ActionListener listener) {
item.setText(name);
item.setSelected(init);
if (listener != null) {
item.addActionListener(listener);
}
return item;
}
}
代码示例来源:origin: chatty/chatty
public void setSorting(String key) {
JMenuItem item = getItem("sort_"+key);
if (item != null) {
item.setSelected(true);
}
}
代码示例来源:origin: edu.utah.bmi.nlp/nlp-core
private void setCasInitializerPanelVisible(boolean visible) {
casInitializerPanel.setVisible(visible);
if (viewCasInitializerPanelMenuItem != null) {
viewCasInitializerPanelMenuItem.setSelected(visible);
}
if (visible) {
readerInitializerSplitPane.setDividerLocation(0.5);
}
}
代码示例来源:origin: chatty/chatty
public void setRange(int range) {
String key = "historyRange"+range;
JMenuItem item = getItem(key);
if (item != null) {
item.setSelected(true);
}
}
代码示例来源:origin: igvteam/igv
public void addViewAsPairsMenuItem() {
final JMenuItem item = new JCheckBoxMenuItem("View as pairs");
item.setSelected(renderOptions.isViewPairs());
item.addActionListener(aEvt -> {
boolean viewAsPairs = item.isSelected();
setViewAsPairs(viewAsPairs);
});
item.setEnabled(dataManager.isPairedEnd());
add(item);
}
代码示例来源:origin: org.fudaa.framework.ctulu/ctulu-ui
private static void updateMenu(final JMenu _m,final String actionCommand){
for (int i = _m.getMenuComponentCount() - 1; i >= 0; i--) {
if (_m.getMenuComponent(i) instanceof JMenuItem) {
final JMenuItem it = (JMenuItem) _m.getMenuComponent(i);
it.setSelected(it.getActionCommand().equals(actionCommand));
}
}
}
代码示例来源:origin: igvteam/igv
public JMenuItem addQuickConsensusModeItem() {
// Change track height by attribute
final JMenuItem item = new JCheckBoxMenuItem("Quick consensus mode");
item.setSelected(renderOptions.isQuickConsensusMode());
item.addActionListener(aEvt -> {
renderOptions.setQuickConsensusMode(item.isSelected());
refresh();
});
add(item);
return item;
}
代码示例来源:origin: com.jidesoft/jide-oss
@Override
protected void uninstallDefaults() {
menuItem.setArmed(false);
menuItem.setSelected(false);
menuItem.resetKeyboardActions();
super.uninstallDefaults();
}
代码示例来源:origin: xyz.cofe/docking-frames-core
public void actionPerformed( ActionEvent e ){
if( action.isDropDownTriggerable( dockable, false ))
itemTriggered();
else
item.setSelected( action.isSelected( dockable ));
}
代码示例来源:origin: org.biojava.thirdparty/forester
static JMenuItem customizeMenuItemAsLabel( final JMenuItem label, final Configuration configuration ) {
label.setFont( MainFrame.menu_font.deriveFont( Font.BOLD ) );
if ( !configuration.isUseNativeUI() ) {
label.setBackground( configuration.getGuiMenuBackgroundColor() );
label.setForeground( configuration.getGuiMenuTextColor() );
label.setOpaque( true );
}
label.setSelected( false );
label.setEnabled( false );
return label;
}
内容来源于网络,如有侵权,请联系作者删除!