java.awt.MenuItem.setEnabled()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(6.1k)|赞(0)|评价(0)|浏览(149)

本文整理了Java中java.awt.MenuItem.setEnabled()方法的一些代码示例,展示了MenuItem.setEnabled()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.setEnabled()方法的具体详情如下:
包路径:java.awt.MenuItem
类名称:MenuItem
方法名:setEnabled

暂无

代码示例

代码示例来源:origin: stackoverflow.com

@Override
public void onPrepareOptionsMenu(Menu menu) {
  MenuItem item= menu.findItem(R.id.men_1);
  item.setEnabled(false);
  super.onPrepareOptionsMenu(menu);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  MenuItem item;
  item = menu.findItem(R.id.menu_id_one);
  if (aBooleanVariable) {
    item.setEnabled(true);
  } else {
    item.setEnabled(false);
  }
  // More code...
  return super.onPrepareOptionsMenu(menu);
}

@Override
public boolean onOptionsItemSelected(MenuItem i) {
  // Code, calculations...
  // ...
  // ...
  return super.onOptionsItemSelected(i);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  MenuItem item= menu.findItem(R.id.men_1);
  //depending on your conditions, either enable/disable
  item.setEnabled(false);
  super.onPrepareOptionsMenu(menu);
  return true;
}

代码示例来源:origin: stackoverflow.com

public boolean onPrepareOptionsMenu(Menu menu) {
  boolean menusEnabled = reachedEndOfSlidehow(); // enable or disable?
  MenuItem item = menu.findItem(R.id.menu_next_slide);
  Drawable resIcon = getResources().getDrawable(R.drawable.ic_next_slide);

  if (!menusEnabled)
    resIcon.mutate().setColorFilter(Color.GRAY, PorterDuff.Mode.SRC_IN);

  item.setEnabled(menusEnabled); // any text will be automatically disabled
  item.setIcon(resIcon);
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

  MenuItem item = menu.findItem(R.id.menu_my_item);

  if (myItemShouldBeEnabled) {
    item.setEnabled(true);
    item.getIcon().setAlpha(255);
  } else {
    // disabled
    item.setEnabled(false);
    item.getIcon().setAlpha(130);
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

  MenuItem item = menu.findItem(R.id.menu_my_item);

  if (myItemShouldBeEnabled) {
    item.setEnabled(true);
    item.getIcon().setAlpha(255);
  } else {
    // disabled
    item.setEnabled(false);
    item.getIcon().setAlpha(130);
  }
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {

  // Check current message count
  boolean haveMessages = mMessageCount != 0;

  // Set 'delete' menu item state depending on count
  MenuItem deleteItem = menu.findItem(R.id.menu_delete);
  deleteItem.setTitle(haveMessages ? R.string.delete : R.string.no_messages);
  deleteItem.setEnabled(haveMessages);

  return super.onPrepareOptionsMenu(menu);
}

代码示例来源:origin: stackoverflow.com

private MenuItem securedConnection;
private MenuItem insecuredConnection;

@Override
public boolean onCreateOptionsMenu(Menu menu) {
  MenuInflater inflater = getMenuInflater();
  inflater.inflate(R.menu.connect_menu, menu);
  securedConnection = menu.getItem(0);
  insecuredConnection =  menu.getItem(1);
  return true;
}

public void foo(){
    securedConnection.setEnabled(true);
}

代码示例来源:origin: igniterealtime/Openfire

startMenuItem.setEnabled(false);
stopMenuItem.setEnabled(true);
startButton.setEnabled(true);
stopButton.setEnabled(false);
browserMenuItem.setEnabled(false);
startMenuItem.setEnabled(true);
stopMenuItem.setEnabled(false);

代码示例来源:origin: igniterealtime/Openfire

browserMenuItem.setEnabled(false);
stopMenuItem.setEnabled(false);

代码示例来源:origin: i2p/i2p.i2p

_browserItem.setEnabled(!imminent);
if (_configItem != null)
  _configItem.setEnabled(!imminent);
if (_restartItem != null)
  _restartItem.setEnabled(!x);
if (_stopItem != null)
  _stopItem.setEnabled(!x);
if (_restartHardItem != null)
  _restartHardItem.setEnabled(!imminent);
if (_stopHardItem != null)
  _stopHardItem.setEnabled(!imminent);
if (_cancelItem != null)
  _cancelItem.setEnabled(x && !imminent);

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu (Menu menu){
  super.onPrepareOptionsMenu(menu);

  MenuItem button = menu.findItem(R.id.whatever_menu_button);

  if(menuButtonIsEnabled){
    button.setEnabled(true);
  } else {
    button.setEnabled(false);
  } 
  return true; 
}

代码示例来源:origin: stackoverflow.com

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  boolean ok = super.onPrepareOptionsMenu(menu);
  if (ok) {
    MenuItem item = menu.findItem(id_for_this_screen);
    if (item != null) {
      item.setEnabled(false);
    }
  }
  return ok;
}

代码示例来源:origin: stackoverflow.com

MenuItem menu1;

public boolean onCreateOptionsMenu(Menu menu) {
  menu1 = menu.add(0, 0, 0, "Menu1");
}

public void someOtherMethod() {
  if(menu1 != null) {
    // if it's null, options menu hasn't been created, so nevermind
    menu1.setEnabled(false);
  }
}

代码示例来源:origin: stackoverflow.com

public void updateNavView(NavigationView navView, int resId, String count){
  MenuItem item = navView.getMenu().findItem(resId); //ex. R.id.nav_item_friends
    //MenuItemCompat.setActionView(item, R.layout.badge);
    RelativeLayout notifCount = (RelativeLayout) MenuItemCompat.getActionView(item);
    TextView tv = (TextView) notifCount.findViewById(R.id.textMenuItemCount);

    if (count != null) {
      tv.setText(count);
    }else{
      tv.setText("");
      item.setEnabled(false);
    }
}

代码示例来源:origin: stackoverflow.com

@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  MenuItem search = menu.findItem(R.id.action_search);
  search.setEnabled(false);
  search.setVisible(false);
  super.onCreateOptionsMenu(menu, inflater);
}

代码示例来源:origin: com.dorkbox/SystemTray

@Override
  public
  void run() {
    _native.setEnabled(menuItem.getEnabled());
  }
});

代码示例来源:origin: stackoverflow.com

@Override
 public boolean onPrepareOptionsMenu(Menu menu) {
  // TODO Auto-generated method stub
  MenuItem item = menu.findItem(R.id.action_delete);
  //show the action item
  if  (your condition) {
    item.setEnabled(true);
    item.setVisible(true);
  }
  super.onPrepareOptionsMenu(menu);
  return true;
}

代码示例来源:origin: net.imagej/ij

private void enableDisableMenuItems() {
  boolean frozen = plot.isFrozen();	//prepare menu according to 'frozen' state of plot
  ((CheckboxMenuItem)menuItems[FREEZE]).setState(frozen);
  for (int i : DISABLED_WHEN_FROZEN)
    menuItems[i].setEnabled(!frozen);
  if (!PlotContentsDialog.tableWindowExists())
    menuItems[ADD_FROM_TABLE].setEnabled(false);
  if (plot.getDataObjectDesignations().length == 0)
    menuItems[ADD_FIT].setEnabled(false);
}

代码示例来源:origin: sc.fiji/TrakEM2_

static private void restoreMenu(final Menu menu) {
  final int n_menuitems = menu.getItemCount();
  for (int i=0; i<n_menuitems; i++) {
    final MenuItem menu_item = menu.getItem(i);
    if (menu_item instanceof Menu) {
      restoreMenu((Menu)menu_item);
    }
    menu_item.setEnabled(true);
  }
}

相关文章