/** * Inserts a new menu item with the specified text at a given position. * * @param s the text for the menu item to add * @param pos an integer specifying the position at which to add the new menu item * @exception IllegalArgumentException when the value of <code>pos</code> < 0 */ @Override public void insert(String s, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } popupMenu.insert(new JMenuItem(s), pos); }
/** * Inserts a new menu item attached to the specified <code>Action</code> object at a given * position. * * @param a the <code>Action</code> object for the menu item to add * @param pos an integer specifying the position at which to add the new menu item * @exception IllegalArgumentException if the value of <code>pos</code> < 0 */ @Override public JMenuItem insert(Action a, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } SJMenuItem mi = new SJMenuItem(a, itemID); popupMenu.insert(mi, pos); return mi; }
/** * Inserts the specified <code>JMenuitem</code> at a given position. * * @param mi the <code>JMenuitem</code> to add * @param pos an integer specifying the position at which to add the new <code>JMenuitem</code> * @return the new menu item * @exception IllegalArgumentException if the value of <code>pos</code> < 0 */ @Override public JMenuItem insert(JMenuItem mi, int pos) { if (pos < 0) { throw new IllegalArgumentException("index less than zero."); } AccessibleContext ac = mi.getAccessibleContext(); ac.setAccessibleParent(this); popupMenu.insert(mi, pos); return mi; }