本文整理匯總了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);
}
}