当前位置: 首页>>代码示例>>Java>>正文


Java JPopupMenu.remove方法代码示例

本文整理汇总了Java中javax.swing.JPopupMenu.remove方法的典型用法代码示例。如果您正苦于以下问题:Java JPopupMenu.remove方法的具体用法?Java JPopupMenu.remove怎么用?Java JPopupMenu.remove使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.JPopupMenu的用法示例。


在下文中一共展示了JPopupMenu.remove方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: checkSeparators

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
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;
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:DynaMenuModel.java

示例2: createPopupMenu

import javax.swing.JPopupMenu; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:57,代码来源:PolarChartPanel.java


注:本文中的javax.swing.JPopupMenu.remove方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。