Beispiel #1
0
  @Override
  public JPopupMenu getComponentPopupMenu() {
    if (popupMenu == null) {
      popupMenu = new JPopupMenu(Messages.CHART_COLON);
      timeRangeMenu = new JMenu(Messages.PLOTTER_TIME_RANGE_MENU);
      timeRangeMenu.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_TIME_RANGE_MENU));
      popupMenu.add(timeRangeMenu);
      menuRBs = new JRadioButtonMenuItem[rangeNames.length];
      ButtonGroup rbGroup = new ButtonGroup();
      for (int i = 0; i < rangeNames.length; i++) {
        menuRBs[i] = new JRadioButtonMenuItem(rangeNames[i]);
        rbGroup.add(menuRBs[i]);
        menuRBs[i].addActionListener(this);
        if (viewRange == rangeValues[i]) {
          menuRBs[i].setSelected(true);
        }
        timeRangeMenu.add(menuRBs[i]);
      }

      popupMenu.addSeparator();

      saveAsMI = new JMenuItem(Messages.PLOTTER_SAVE_AS_MENU_ITEM);
      saveAsMI.setMnemonic(Resources.getMnemonicInt(Messages.PLOTTER_SAVE_AS_MENU_ITEM));
      saveAsMI.addActionListener(this);
      popupMenu.add(saveAsMI);
    }
    return popupMenu;
  }
Beispiel #2
0
 /**
  * Factory method which creates the <code>JMenuItem</code> for <code>Actions</code> added to the
  * <code>JPopupMenu</code>.
  *
  * @param a the <code>Action</code> for the menu item to be added
  * @return the new menu item
  * @see Action
  * @since 1.3
  */
 protected JMenuItem createActionComponent(Action a) {
   JMenuItem mi =
       new JMenuItem() {
         protected PropertyChangeListener createActionPropertyChangeListener(Action a) {
           PropertyChangeListener pcl = createActionChangeListener(this);
           if (pcl == null) {
             pcl = super.createActionPropertyChangeListener(a);
           }
           return pcl;
         }
       };
   mi.setHorizontalTextPosition(JButton.TRAILING);
   mi.setVerticalTextPosition(JButton.CENTER);
   return mi;
 }
Beispiel #3
0
 /**
  * Inserts a menu item for the specified <code>Action</code> object at a given position.
  *
  * @param a the <code>Action</code> object to insert
  * @param index specifies the position at which to insert the <code>Action</code>, where 0 is the
  *     first
  * @exception IllegalArgumentException if <code>index</code> < 0
  * @see Action
  */
 public void insert(Action a, int index) {
   JMenuItem mi = createActionComponent(a);
   mi.setAction(a);
   insert(mi, index);
 }
Beispiel #4
0
 /**
  * Returns a properly configured <code>PropertyChangeListener</code> which updates the control as
  * changes to the <code>Action</code> occur.
  */
 protected PropertyChangeListener createActionChangeListener(JMenuItem b) {
   return b.createActionPropertyChangeListener0(b.getAction());
 }
Beispiel #5
0
 /**
  * Appends a new menu item to the end of the menu which dispatches the specified <code>Action
  * </code> object.
  *
  * @param a the <code>Action</code> to add to the menu
  * @return the new menu item
  * @see Action
  */
 public JMenuItem add(Action a) {
   JMenuItem mi = createActionComponent(a);
   mi.setAction(a);
   add(mi);
   return mi;
 }