void handleRightClick(MouseEvent me, int nPosX, int nPosY) {
	
			ActionListener act = new ActionListener() {
				public void actionPerformed(ActionEvent ae) {
					if (ae.getActionCommand().equals("Add node")) {
						a_addnode.addNode(m_nPosX, m_nPosY);
						return;
					}
					repaint();
				}
			};
			JPopupMenu popupMenu = new JPopupMenu("Choose a value");

			JMenuItem addNodeItem = new JMenuItem("Add node");
			addNodeItem.addActionListener(act);
			popupMenu.add(addNodeItem);

			FastVector selected = m_Selection.getSelected();
			JMenu addArcMenu = new JMenu("Add parent");
			popupMenu.add(addArcMenu);
			if (selected.size() == 0) {
				addArcMenu.setEnabled(false);
			} else {
			int nNodes = m_BayesNet.getNrOfNodes();
			boolean[] isNotAllowedAsParent = new boolean[nNodes];
			// prevent it being a parent of itself
			for (int iNode = 0; iNode < selected.size(); iNode++) {
				isNotAllowedAsParent[(Integer) selected.elementAt(iNode)] = true;
			}
			// prevent a descendant being a parent, since it introduces cycles
			for (int i = 0; i < nNodes; i++) {
				for (int iNode = 0; iNode < nNodes; iNode++) {
					for (int iParent = 0; iParent < m_BayesNet.getNrOfParents(iNode); iParent++) {
						if (isNotAllowedAsParent[m_BayesNet.getParent(iNode, iParent)]) {
							isNotAllowedAsParent[iNode] = true;
						}
					}
				}
			}
			// prevent nodes that are already a parent
			for (int iNode = 0; iNode < selected.size(); iNode++) {
				int nNode = (Integer) selected.elementAt(iNode);
				for (int iParent = 0; iParent < m_BayesNet.getNrOfParents(nNode); iParent++) {
					isNotAllowedAsParent[m_BayesNet.getParent(nNode, iParent)] = true;
				}
			}
			ActionListener addParentAction = new ActionListener() {
				public void actionPerformed(ActionEvent ae) {
					try {
						m_BayesNet.addArc(ae.getActionCommand(), m_Selection.getSelected());
						m_jStatusBar.setText(m_BayesNet.lastActionMsg());
						updateStatus();
					} catch (Exception e) {
						e.printStackTrace();
					}
				}
			};
			// count nr of remaining candidates
			int nCandidates = 0;
			for (int i = 0; i < nNodes; i++) {
				if (!isNotAllowedAsParent[i]) {
					JMenuItem item = new JMenuItem(m_BayesNet.getNodeName(i));
					item.addActionListener(addParentAction);
					addArcMenu.add(item);
					nCandidates++;
				}
			}
			if (nCandidates == 0) {
				addArcMenu.setEnabled(false);
			}
			}
			m_nPosX = nPosX;
			m_nPosY = nPosY;
			popupMenu.setLocation(me.getX(), me.getY());
			popupMenu.show(m_GraphPanel, me.getX(), me.getY());
	    }