Java Code Examples for javax.swing.JPopupMenu#remove()

The following examples show how to use javax.swing.JPopupMenu#remove() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DynaMenuModel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
static void checkSeparators(Component[] menuones, JPopupMenu parent) {
    boolean wasSeparator = false;
    for (int i = 0; i < menuones.length; i++) {
        Component curItem = menuones[i];
        if (curItem != null) {
            boolean isSeparator = curItem instanceof JSeparator;
            if (isSeparator) {
                boolean isVisible = curItem.isVisible();
                if (isVisible != !wasSeparator) {
                    //MACOSX whenever a property like enablement or visible is changed, need to remove and add.
                    // could be possibly split to work differetly on other platform..
                    parent.remove(i);
                    JSeparator newOne = createSeparator();
                    newOne.setVisible(!wasSeparator);
                    parent.add(newOne, i);
                }
            }
            if (!(curItem instanceof InvisibleMenuItem)) {
                wasSeparator = isSeparator;
            }
        }
    }
}
 
Example 2
Source File: PolarChartPanel.java    From openstock with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 3
Source File: PolarChartPanel.java    From ccu-historian with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 4
Source File: PolarChartPanel.java    From SIMVA-SoS with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 5
Source File: PolarChartPanel.java    From ECG-Viewer with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 6
Source File: PolarChartPanel.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties,
                                     boolean save,
                                     boolean print,
                                     boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex  = getPopupMenuItem(result, "Zoom In");
   int zoomOutIndex = getPopupMenuItem(result, "Zoom Out");
   int autoIndex     = getPopupMenuItem(result, "Auto Range");
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem("Zoom In");
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem("Zoom Out");
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem("Auto Range");
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 7
Source File: PolarChartPanel.java    From astor with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties,
                                     boolean save, 
                                     boolean print, 
                                     boolean zoom) {
    
   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex  = getPopupMenuItem(result, "Zoom In");
   int zoomOutIndex = getPopupMenuItem(result, "Zoom Out");
   int autoIndex     = getPopupMenuItem(result, "Auto Range");
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem("Zoom In");
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);
      
       JMenuItem zoomOut = new JMenuItem("Zoom Out");
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);
      
       JMenuItem auto = new JMenuItem("Auto Range");
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);
      
       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 8
Source File: PolarChartPanel.java    From opensim-gui with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
protected JPopupMenu createPopupMenu(boolean properties,
                                     boolean save, 
                                     boolean print, 
                                     boolean zoom) {
    
   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex  = getPopupMenuItem(result, "Zoom In");
   int zoomOutIndex = getPopupMenuItem(result, "Zoom Out");
   int autoIndex     = getPopupMenuItem(result, "Auto Range");
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem("Zoom In");
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);
      
       JMenuItem zoomOut = new JMenuItem("Zoom Out");
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);
      
       JMenuItem auto = new JMenuItem("Auto Range");
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);
      
       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 9
Source File: PolarChartPanel.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}
 
Example 10
Source File: PolarChartPanel.java    From buffer_bci with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Creates a popup menu for the panel.
 *
 * @param properties  include a menu item for the chart property editor.
 * @param save  include a menu item for saving the chart.
 * @param print  include a menu item for printing the chart.
 * @param zoom  include menu items for zooming.
 *
 * @return The popup menu.
 */
@Override
protected JPopupMenu createPopupMenu(boolean properties, boolean save,
        boolean print, boolean zoom) {

   JPopupMenu result = super.createPopupMenu(properties, save, print, zoom);
   int zoomInIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_In"));
   int zoomOutIndex = getPopupMenuItem(result,
           localizationResources.getString("Zoom_Out"));
   int autoIndex = getPopupMenuItem(result,
           localizationResources.getString("Auto_Range"));
   if (zoom) {
       JMenuItem zoomIn = new JMenuItem(
               localizationResources.getString("Zoom_In"));
       zoomIn.setActionCommand(POLAR_ZOOM_IN_ACTION_COMMAND);
       zoomIn.addActionListener(this);

       JMenuItem zoomOut = new JMenuItem(
               localizationResources.getString("Zoom_Out"));
       zoomOut.setActionCommand(POLAR_ZOOM_OUT_ACTION_COMMAND);
       zoomOut.addActionListener(this);

       JMenuItem auto = new JMenuItem(
               localizationResources.getString("Auto_Range"));
       auto.setActionCommand(POLAR_AUTO_RANGE_ACTION_COMMAND);
       auto.addActionListener(this);

       if (zoomInIndex != -1) {
           result.remove(zoomInIndex);
       }
       else {
           zoomInIndex = result.getComponentCount() - 1;
       }
       result.add(zoomIn, zoomInIndex);
       if (zoomOutIndex != -1) {
           result.remove(zoomOutIndex);
       }
       else {
           zoomOutIndex = zoomInIndex + 1;
       }
       result.add(zoomOut, zoomOutIndex);
       if (autoIndex != -1) {
           result.remove(autoIndex);
       }
       else {
           autoIndex = zoomOutIndex + 1;
       }
       result.add(auto, autoIndex);
   }
   return result;
}