java.awt.Menu.add()方法的使用及代码示例

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

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

暂无

代码示例

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

private static final int NEW_MENU_ID=Menu.FIRST+1;

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

    menu.add(0, NEW_MENU_ID, 0, "New"); 

    return true;
  }

代码示例来源:origin: wildfly/wildfly

private MenuBar createMenuBar() {
  MenuBar ret=new MenuBar();
  Menu file=new Menu("File");
  MenuItem quitm=new MenuItem("Quit");
  ret.setFont(def_font2);
  ret.add(file);
  file.addSeparator();
  file.add(quitm);
  quitm.addActionListener(e -> System.exit(1));
  return ret;
}

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

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

 menu.add(Menu.NONE, R.id.menu_action1, Menu.NONE, R.string.menu_action1);
 menu.add(Menu.NONE, R.id.menu_action2, Menu.NONE, R.string.menu_action1);

 return true;
}

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

/*************************************/
/* Create the actionbar options menu */
/*************************************/
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
  menu.add(0, 0, 0, "History").setIcon(R.drawable.ic_menu_recent_history)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
  menu.add(0, 1, 0, "Settings").setIcon(R.drawable.ic_menu_manage)
      .setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

  return true;
}

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

public boolean onCreateOptionsMenu(Menu menu) {
 MenuItem item = menu.add ("Clear Array");
 item.setOnMenuItemClickListener (new OnMenuItemClickListener(){
  @Override
  public boolean onMenuItemClick (MenuItem item){
   clearArray();
   return true;
  }
 });
 return true;
}

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

private static final int MENU_LOGOUT = MENU.FIRST + 4;
 public boolean onPrepareOptionsMenu(Menu menu) {
   ...
   if(auth.isLoggedIn()) {
     menu.add(0, MENU_LOGOUT, Menu.NONE, R.string.your-logout-text).setIcon(R.drawable.your-logout-icon);
   }
   ...
 }
 public boolean onOptionsItemSelected(MenuItem item) {
   ...
   case MENU_LOGOUT:
     if(auth.isLoggedIn()) {
       doLogout();
     } else {
       Toast.makeText(this, "You must have somehow been logged out between the time the menu button was pressed and now.", Toast.DURATION_LONG).show();
     }
     break;
   ...
 }

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

@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  menu.clear();
  if(isChangedStat) {
    menu.add(0, MENUITEM, 0, "True");
  } else {
    menu.add(0, MENUITEM, 0, "False");
  }
  return super.onPrepareOptionsMenu(menu);
}

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

private static final int MENU_ITEM_ITEM1 = 1;
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
  menu.add(Menu.NONE, MENU_ITEM_ITEM1, Menu.NONE, "Item name");
  return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
  switch (item.getItemId()) {
  case MENU_ITEM_ITEM1:
    clearArray();
    return true;

  default:
    return false;
 }
}

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

public static final int MENU_ADD = Menu.FIRST;
public static final int MENU_DELETE = Menu.FIRST + 1;

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

  menu.add(Menu.NONE, MENU_ADD, Menu.NONE, "Add");
  menu.add(Menu.NONE, MENU_DELETE, Menu.NONE, "Delete");
  return true;
}

  @Override
  public boolean onOptionsItemSelected(MenuItem item)
  {
    switch(item.getItemId())
    {
      case MENU_ADD:

      return true;
    case MENU_DELETE:

      return true;
    default:
      return super.onOptionsItemSelected(item);
    }
  }

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

public boolean onCreateOptionsMenu(Menu menu) {
  menu.add(0, REFRESH, 0, "Refresh")
    .setIcon(R.drawable.ic_action_refresh)
    .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);
  menu.add(0, SEARCH, 0, "Search")
    .setIcon(R.drawable.ic_action_search)
    .setShowAsAction(MenuItem.SHOW_AS_ACTION_ALWAYS);

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

menu.add(group1Id, homeId, homeId, "").setIcon(R.drawable.home_menu);
menu.add(group1Id, profileId, profileId, "").setIcon(R.drawable.profile_menu);
menu.add(group1Id, searchId, searchId, "").setIcon(R.drawable.search_menu);
menu.add(group1Id, dealsId, dealsId, "").setIcon(R.drawable.deals_menu);
menu.add(group1Id, helpId, helpId, "").setIcon(R.drawable.help_menu);
menu.add(group1Id, contactusId, contactusId, "").setIcon(R.drawable.contactus_menu);

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

menu.clear();
if(enableAdd)
  menu.add(0, MENU_ADD, Menu.NONE, R.string.your-add-text).setIcon(R.drawable.your-add-icon);
if(enableList)
  menu.add(0, MENU_LIST, Menu.NONE, R.string.your-list-text).setIcon(R.drawable.your-list-icon);
if(enableRefresh)
  menu.add(0, MENU_REFRESH, Menu.NONE, R.string.your-refresh-text).setIcon(R.drawable.your-refresh-icon);
if(enableLogin)
  menu.add(0, MENU_LOGIN, Menu.NONE, R.string.your-login-text).setIcon(R.drawable.your-login-icon);
return super.onPrepareOptionsMenu(menu);

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

public boolean onCreateOptionsMenu(Menu menu) {
  menu.add("Overflow");
  return super.onCreateOptionsMenu(menu);

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

MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

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

MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

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

menu.add(runWait);
super.makeMenu(menu, instance);

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

public boolean onCreateOptionsMenu(Menu menu)
  menu.add(0, 0, 0, "StartRecording");
  menu.add(0, 1, 0, "StopRecording");
  return super.onCreateOptionsMenu(menu);

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

MenuItem defaultItem=new MenuItem("Exit");
defaultItem.addActionListener(exitListener);
popup.add(defaultItem);
defaultItem=new MenuItem("Open");
defaultItem.addActionListener(new ActionListener() {
popup.add(defaultItem);
trayIcon=new TrayIcon(image, "SystemTray Demo", popup);
trayIcon.setImageAutoSize(true);

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

@Override public boolean onCreateOptionsMenu(Menu menu)
{
  getMenuInflater().inflate(R.menu.base, menu); // All menus in base.xml
  getMenuInflater().inflate(R.menu.extras, menu); // base.xml + extras.xml
  menu.add("More"); // base.xml + extras.xml + "More"
  return true;
}

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

popup.add(showItem);
popup.add(closeItem);

相关文章