本文整理汇总了Java中java.awt.PopupMenu.insert方法的典型用法代码示例。如果您正苦于以下问题:Java PopupMenu.insert方法的具体用法?Java PopupMenu.insert怎么用?Java PopupMenu.insert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.PopupMenu
的用法示例。
在下文中一共展示了PopupMenu.insert方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteConnectionPopup
import java.awt.PopupMenu; //导入方法依赖的package包/类
/**
* Popup a menu giving choices for connections to delete (if any)
*
* @param closestConnections a vector containing 0 or more BeanConnections
* @param x the x coordinate at which to popup the menu
* @param y the y coordinate at which to popup the menu
*
* Modified by Zerbetto: javax.swing.JPopupMenu transformed into java.awt.PopupMenu
*/
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
if (closestConnections.size() > 0) {
int menuItemCount = 0;
// modifications by Zerbetto
//JPopupMenu deleteConnectionMenu = new JPopupMenu();
PopupMenu deleteConnectionMenu = new PopupMenu();
// deleteConnectionMenu.insert(new JLabel("Delete Connection",
// SwingConstants.CENTER),
// menuItemCount);
MenuItem deleteConnection = new MenuItem("Delete Connection:");
deleteConnection.setEnabled(false);
deleteConnectionMenu.insert(deleteConnection, menuItemCount);
menuItemCount++;
for (int i = 0; i < closestConnections.size(); i++) {
final BeanConnection bc = (BeanConnection) closestConnections.elementAt(i);
String connName = bc.getSourceEventSetDescriptor().getName();
//JMenuItem deleteItem = new JMenuItem(connName);
String targetName = "";
if (bc.getTarget().getBean() instanceof BeanCommon) {
targetName = ((BeanCommon)bc.getTarget().getBean()).getCustomName();
} else {
targetName = bc.getTarget().getBean().getClass().getName();
targetName = targetName.substring(targetName.lastIndexOf('.')+1, targetName.length());
}
MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
deleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bc.remove(m_mainKFPerspective.getCurrentTabIndex());
m_beanLayout.revalidate();
m_beanLayout.repaint();
m_mainKFPerspective.setEditedStatus(true);
notifyIsDirty();
}
});
deleteConnectionMenu.add(deleteItem);
menuItemCount++;
}
//deleteConnectionMenu.show(m_beanLayout, x, y);
m_beanLayout.add(deleteConnectionMenu);
deleteConnectionMenu.show(m_beanLayout, x, y);
}
}
示例2: deleteConnectionPopup
import java.awt.PopupMenu; //导入方法依赖的package包/类
/**
* Popup a menu giving choices for connections to delete (if any)
*
* @param closestConnections a vector containing 0 or more BeanConnections
* @param x the x coordinate at which to popup the menu
* @param y the y coordinate at which to popup the menu
*
* Modified by Zerbetto: javax.swing.JPopupMenu transformed into
* java.awt.PopupMenu
*/
private void deleteConnectionPopup(Vector closestConnections, int x, int y) {
if (closestConnections.size() > 0) {
int menuItemCount = 0;
// modifications by Zerbetto
// JPopupMenu deleteConnectionMenu = new JPopupMenu();
PopupMenu deleteConnectionMenu = new PopupMenu();
// deleteConnectionMenu.insert(new JLabel("Delete Connection",
// SwingConstants.CENTER),
// menuItemCount);
MenuItem deleteConnection = new MenuItem(
Messages
.getInstance()
.getString(
"KnowledgeFlowApp_DeleteConnectionPopup_DeleteConnection_MenuItem_Text"));
deleteConnection.setEnabled(false);
deleteConnectionMenu.insert(deleteConnection, menuItemCount);
menuItemCount++;
for (int i = 0; i < closestConnections.size(); i++) {
final BeanConnection bc = (BeanConnection) closestConnections
.elementAt(i);
String connName = bc.getSourceEventSetDescriptor().getName();
// JMenuItem deleteItem = new JMenuItem(connName);
String targetName = "";
if (bc.getTarget().getBean() instanceof BeanCommon) {
targetName = ((BeanCommon) bc.getTarget().getBean()).getCustomName();
} else {
targetName = bc.getTarget().getBean().getClass().getName();
targetName = targetName.substring(targetName.lastIndexOf('.') + 1,
targetName.length());
}
MenuItem deleteItem = new MenuItem(connName + "-->" + targetName);
deleteItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
bc.remove();
m_beanLayout.revalidate();
m_beanLayout.repaint();
notifyIsDirty();
}
});
deleteConnectionMenu.add(deleteItem);
menuItemCount++;
}
// deleteConnectionMenu.show(m_beanLayout, x, y);
m_beanLayout.add(deleteConnectionMenu);
deleteConnectionMenu.show(m_beanLayout, x, y);
}
}