Menu
Code IndexAdd Codota to your IDE (free)

Best code snippets using java.awt.Menu(Showing top 20 results out of 324)

Refine search

  • MenuItem
  • MenuItem
  • MenuBar
  • MenuInflater
  • PopupMenu
  • Menus
  • SystemTray
  • TrayIcon
  • Stage
  • Common ways to obtain Menu
private void myMethod () {
Menu m =
  • String str;new Menu(str)
  • MenuBar menuBar;menuBar.getMenu(int1)
  • Smart code suggestions by Codota
}
origin: stackoverflow.com

 //anywhere in your code
...
mState = HIDE_MENU; // setting state
invalidateOptionsMenu(); // now onCreateOptionsMenu(...) is called again
...

@Override
public boolean onCreateOptionsMenu(Menu menu)
{
  // inflate menu from xml
  MenuInflater inflater = getSupportMenuInflater();
  inflater.inflate(R.menu.settings, menu);

  if (mState == HIDE_MENU)
  {
    for (int i = 0; i < menu.size(); i++)
      menu.getItem(i).setVisible(false);
  }
}
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);
super.onOptionsItemSelected(item);
switch (item.getItemId()) {
case MENU_ADD: doAddStuff(); break;
case MENU_LIST: doListStuff(); break;
origin: stackoverflow.com

MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
item.setActionView(sv);
origin: stackoverflow.com

MenuItem item = menu.add("Search");
item.setIcon(android.R.drawable.ic_menu_search);
item.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);
SearchView sv = new SearchView(getActivity());
sv.setOnQueryTextListener(this);
item.setActionView(sv);
origin: stackoverflow.com

 @Override
public boolean onCreateOptionsMenu(Menu menu) {
  getSupportMenuInflater().inflate(R.menu.map_menu, menu);
  for (int i = 0; i < menu.size(); i++) {
    MenuItem item = menu.getItem(i);
    if (item.getItemId() == R.id.menu_more) {
      itemChooser = item.getActionView();
      if (itemChooser != null) {
        itemChooser.setOnClickListener(this);
      }
    }
  }
  return super.onCreateOptionsMenu(menu);
}
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(
      new ActionListener() {
        public void actionPerformed(ActionEvent e) {
          System.exit(1);
        }
      });
  return ret;
}
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

 @Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
  inflater.inflate(R.menu.your_menu, menu);

  int positionOfMenuItem = 0; // or whatever...
  MenuItem item = menu.getItem(positionOfMenuItem);
  SpannableString s = new SpannableString("My red MenuItem");
  s.setSpan(new ForegroundColorSpan(Color.RED), 0, s.length(), 0);
  item.setTitle(s);
}
origin: stackoverflow.com

MenuBar menuBar = new MenuBar();
menuBar.getMenus().addAll(new Menu("School"), new Menu("Social"), new Menu("Network"));
TreeItem<String> root = new TreeItem<>("Private Notes");
root.setExpanded(false);
layout.setLeft(optionPane);
layout.setCenter(editorBox);
stage.setScene(new Scene(layout));
stage.show();
origin: stackoverflow.com

  System.out.println("Unable to set LookAndFeel");
if(SystemTray.isSupported()){
  System.out.println("system tray supported");
  tray=SystemTray.getSystemTray();
  PopupMenu popup=new PopupMenu();
  MenuItem defaultItem=new MenuItem("Exit");
  defaultItem.addActionListener(exitListener);
  popup.add(defaultItem);
  defaultItem=new MenuItem("Open");
  defaultItem.addActionListener(new ActionListener() {
    public void actionPerformed(ActionEvent e) {
  popup.add(defaultItem);
  trayIcon=new TrayIcon(image, "SystemTray Demo", popup);
  trayIcon.setImageAutoSize(true);
}else{
  System.out.println("system tray not supported");
    if(e.getNewState()==ICONIFIED){
      try {
        tray.add(trayIcon);
        setVisible(false);
        System.out.println("added to SystemTray");
origin: stackoverflow.com

  menu.add(runWait);
  super.makeMenu(menu, instance);
MenuItem runWait = new MenuItem("wait", 1, 1) {
  public void run() {
    UiApplication.getUiApplication().invokeLater(
origin: stackoverflow.com

  for(int i = 0; i< menu.size(); i++)
    menu.getItem(i).setVisible(!mDrawerLayout.isDrawerOpen(mLeftDrawerView));
public boolean onOptionsItemSelected(MenuItem item) {
  switch(item.getItemId()) {
    case android.R.id.home:
      mDrawerToggle.onOptionsItemSelected(item);
origin: stackoverflow.com

public boolean onCreateOptionsMenu(Menu menu)
  menu.add(0, 0, 0, "StartRecording");
  menu.add(0, 1, 0, "StopRecording");
  return super.onCreateOptionsMenu(menu);
public boolean onOptionsItemSelected(MenuItem item)
  switch (item.getItemId())
origin: stackoverflow.com

 public boolean onCreateOptionsMenu(Menu menu) { 
      MenuInflater inflater = getMenuInflater();
      inflater.inflate(R.menu.mapoptions, menu);

      int idx=0;
      subm = menu.getItem(MYITEM_INDEX).getSubMenu(); // get my MenuItem with placeholder submenu
      subm.clear(); // delete place holder

      while(true)
      {
        anarea = m_areas.GetArea(idx); // get a new area, return null if no more areas
        if(anarea == null)
          break;
        subm.add(0, SUBAREASID+idx, idx, anarea.GetName()); // id is idx+ my constant
        ++idx;
      }
}
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: net.imagej/ij

/** Inserts 'item' into 'menu' in alphanumeric order. */
static void addOrdered(Menu menu, MenuItem item) {
  String label = item.getLabel();
  int start = addPluginSeparatorIfNeeded(menu);
  for (int i=start; i<menu.getItemCount(); i++) {
    if (label.compareTo(menu.getItem(i).getLabel())<0) {
      menu.insert(item, i);
      return;
    }
  }
  menu.add(item);
}

origin: net.imagej/ij

void addOpenRecentSubMenu(Menu menu) {
  openRecentMenu = getMenu("File>Open Recent");
   for (int i=0; i<MAX_OPEN_RECENT_ITEMS; i++) {
    String path = Prefs.getString("recent" + (i/10)%10 + i%10);
    if (path==null) break;
    MenuItem item = new MenuItem(path);
    openRecentMenu.add(item);
    item.addActionListener(ij);
  }
  menu.add(openRecentMenu);
}
origin: net.imagej/ij

public void findAllMenuItems() {
  MenuBar menuBar = Menus.getMenuBar();
  int topLevelMenus = menuBar.getMenuCount();
  for (int i=0; i<topLevelMenus; ++i) {
    Menu topLevelMenu=menuBar.getMenu(i);
    parseMenu(topLevelMenu.getLabel(), topLevelMenu);
  }
}
origin: net.imagej/ij

public int install(String text) {
  if (text==null && pgm==null)
    return 0;
  this.text = text;
  macrosMenu = Menus.getMacrosMenu();
  if (listener!=null)
    macrosMenu.removeActionListener(listener);
  macrosMenu.addActionListener(this);
  listener = this;
  install();
  return nShortcuts;
}

origin: openmicroscopy/bioformats

public SearchableWindow(String title, String headings, String data,
 int w, int h)
{
 super(title, headings, data, w, h);
 index = -1;
 panel = getTextPanel();
 MenuBar menubar = getMenuBar();
 Menu menu = menubar.getMenu(0);
 MenuItem search = new MenuItem("Search...");
 search.setActionCommand("search");
 search.addActionListener(this);
 menu.add(search);
}
java.awtMenu

Most used methods

  • add
  • <init>
  • addSeparator
  • getItem
  • getItemCount
  • getLabel
  • getName
  • insert
  • remove
  • setName
  • FileMenu
  • ViewMenu
  • FileMenu,
  • ViewMenu,
  • addActionListener,
  • addListener,
  • addMenuItem,
  • addMenuListener,
  • addSubMenu,
  • changeContent,
  • checkIsAlreadyStart,
  • clear

Popular classes and methods

  • scheduleAtFixedRate (ScheduledExecutorService)
    Creates and executes a periodic action that becomes enabled first after the given initial delay, and
  • getSystemService (Context)
  • startActivity (Activity)
  • Window (java.awt)
  • PrintStream (java.io)
    Wraps an existing OutputStream and provides convenience methods for writing common data types in a h
  • Permission (java.security)
    Abstract class for representing access to a system resource. All permissions have a name (whose inte
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • JButton (javax.swing)
  • JFrame (javax.swing)

For IntelliJ IDEA,
Android Studio or Eclipse

  • Codota IntelliJ IDEA pluginCodota Android Studio pluginCode IndexSign in
  • EnterpriseFAQAboutContact Us
  • Terms of usePrivacy policyCodeboxFind Usages
Add Codota to your IDE (free)