/** * Adds the specified component to this container at the given position. If <code>index</code> * equals -1, the component will be appended to the end. * * @param c the <code>Component</code> to add * @param index the position at which to insert the component * @return the <code>Component</code> added * @see #remove * @see java.awt.Container#add(Component, int) */ @Override public Component add(Component c, int index) { if (c instanceof JComponent) { AccessibleContext ac = ((JComponent) c).getAccessibleContext(); if (ac != null) { ac.setAccessibleParent(this); } } popupMenu.add(c, index); return c; }
/** * Appends a menu item to the end of this menu. Returns the menu item added. * * @param menuItem the <code>JMenuitem</code> to be added * @return the <code>JMenuItem</code> added */ @Override public JMenuItem add(JMenuItem menuItem) { AccessibleContext ac = menuItem.getAccessibleContext(); ac.setAccessibleParent(this); return popupMenu.add(menuItem); }