本文整理汇总了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;
}
}
}
}
示例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;
}