當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。