buy now
log in

Q: How can I display context menu for diagram elements when they are clicked with right mouse button?

A: Implement DiagramListener.nodeClicked (or linkClicked for links) and show a JMenuPopup, for example:

public void nodeClicked(NodeEvent e)
	final DiagramNode node = e.getNode();
	if (e.getMouseButton() == MouseEvent.BUTTON3)
		JPopupMenu menu = new JPopupMenu();
		menu.add("Delete").addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent actionEvent)
		Point p = diagramView.docToDevice(e.getMousePosition());, p.x, p.y);

Copyright © 2001-2019 MindFusion LLC. All rights reserved.
Terms of Use - Contact Us