示例#1
0
 /**
  * Inserts a separator at the specified position.
  *
  * @param index an integer specifying the position at which to insert the menu separator
  * @exception IllegalArgumentException if the value of <code>index</code> < 0
  */
 @Override
 public void insertSeparator(int index) {
   if (index < 0) {
     throw new IllegalArgumentException("index less than zero.");
   }
   popupMenu.insertSeperator(index);
 }
示例#2
0
  /**
   * 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);
  }
示例#3
0
 /**
  * Constructs a new SJMenu.
  *
  * <p>|---------|---------| | labelID | itemID | |---------| itemID | | itemID | menuID->| itemID
  * | |---------|
  *
  * @param name the name of the menu. This is the text of the menu label.
  * @param labelID This is the ID of the menu button (ie, what is shown by default before anything
  *     is clicked).
  * @param menuID This is the ID of the list of items that shows when you click the menu button.
  * @param itemID This is the ID of the items themselves.
  */
 public SJMenu(String name, String labelID, String menuID, String itemID) {
   super(name);
   setWidgetID(labelID);
   popupMenu = new SJPopupMenu(menuID);
   popupMenu.setInvoker(this);
   this.itemID = itemID;
   delegate = new SJMenuPaintingDelegate(this);
   setIcon(buildIcon());
 }
示例#4
0
 /**
  * Removes the menu item at the specified index from this menu.
  *
  * @param pos the position of the item to be removed
  * @exception IllegalArgumentException if the value of <code>pos</code> < 0, or if <code>pos
  *     </code> is greater than the number of menu items
  */
 @Override
 public void remove(int pos) {
   if (pos < 0) {
     throw new IllegalArgumentException("index less than zero.");
   }
   if (pos > getItemCount()) {
     throw new IllegalArgumentException("index greater than the number of items.");
   }
   if (popupMenu != null) popupMenu.remove(pos);
 }
示例#5
0
  /**
   * 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;
  }
示例#6
0
 /**
  * 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;
 }
示例#7
0
 /**
  * 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;
 }
示例#8
0
  /**
   * Returns an array of <code>Component</code>s of the menu's subcomponents. Note that this returns
   * all <code>Component</code>s in the popup menu, including separators.
   *
   * @return an array of <code>Component</code>s or an empty array if there is no popup menu
   */
  @Override
  public Component[] getMenuComponents() {
    if (popupMenu != null) return popupMenu.getComponents();

    return new Component[0];
  }
示例#9
0
  /**
   * Returns the component at position <code>n</code>.
   *
   * @param n the position of the component to be returned
   * @return the component requested, or <code>null</code> if there is no popup menu
   */
  @Override
  public Component getMenuComponent(int n) {
    if (popupMenu != null) return popupMenu.getComponent(n);

    return null;
  }
示例#10
0
 /**
  * Returns the number of components on the menu.
  *
  * @return an integer containing the number of components on the menu
  */
 @Override
 public int getMenuComponentCount() {
   int componentCount = 0;
   if (popupMenu != null) componentCount = popupMenu.getComponentCount();
   return componentCount;
 }
示例#11
0
 /** Removes all menu items from this menu. */
 @Override
 public void removeAll() {
   if (popupMenu != null) popupMenu.removeAll();
 }
示例#12
0
 /**
  * Removes the component <code>c</code> from this menu.
  *
  * @param c the component to be removed
  */
 @Override
 public void remove(Component c) {
   if (popupMenu != null) popupMenu.remove(c);
 }
示例#13
0
 /**
  * Removes the specified menu item from this menu. If there is no popup menu, this method will
  * have no effect.
  *
  * @param item the <code>JMenuItem</code> to be removed from the menu
  */
 @Override
 public void remove(JMenuItem item) {
   if (popupMenu != null) popupMenu.remove(item);
 }
示例#14
0
 /** Appends a new separator to the end of the menu. */
 @Override
 public void addSeparator() {
   popupMenu.addSeparator();
 }
示例#15
0
 /**
  * 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);
 }
示例#16
0
 @Override
 public boolean isPopupMenuVisible() {
   return popupMenu.isVisible();
 }