editorpopupmenu.java

来自「经典的java图像处理程序源码」· Java 代码 · 共 78 行

JAVA
78
字号
package com.mxgraph.swing.examples.editor;import javax.swing.JMenu;import javax.swing.JPopupMenu;import javax.swing.TransferHandler;import com.mxgraph.swing.examples.editor.EditorActions.HistoryAction;import com.mxgraph.swing.util.mxGraphActions;import com.mxgraph.util.mxResources;public class EditorPopupMenu extends JPopupMenu{	public EditorPopupMenu(BasicGraphEditor editor)	{		boolean selected = !editor.getGraphComponent().getGraph()				.isSelectionEmpty();		add(editor.bind(mxResources.get("undo"), new HistoryAction(true),				"/com/mxgraph/swing/examples/images/undo.gif"));		addSeparator();		add(				editor.bind(mxResources.get("cut"), TransferHandler						.getCutAction(),						"/com/mxgraph/swing/examples/images/cut.gif"))				.setEnabled(selected);		add(				editor.bind(mxResources.get("copy"), TransferHandler						.getCopyAction(),						"/com/mxgraph/swing/examples/images/copy.gif"))				.setEnabled(selected);		add(editor.bind(mxResources.get("paste"), TransferHandler				.getPasteAction(),				"/com/mxgraph/swing/examples/images/paste.gif"));		addSeparator();		add(				editor.bind(mxResources.get("delete"), mxGraphActions						.getDeleteAction(),						"/com/mxgraph/swing/examples/images/delete.gif"))				.setEnabled(selected);		addSeparator();		// Creates the format menu		JMenu menu = (JMenu) add(new JMenu(mxResources.get("format")));		EditorMenuBar.populateFormatMenu(menu, editor);		// Creates the shape menu		menu = (JMenu) add(new JMenu(mxResources.get("shape")));		EditorMenuBar.populateShapeMenu(menu, editor);		addSeparator();		add(				editor.bind(mxResources.get("edit"), mxGraphActions						.getEditAction())).setEnabled(selected);		addSeparator();		add(editor.bind(mxResources.get("selectVertices"), mxGraphActions				.getSelectVerticesAction()));		add(editor.bind(mxResources.get("selectEdges"), mxGraphActions				.getSelectEdgesAction()));		addSeparator();		add(editor.bind(mxResources.get("selectAll"), mxGraphActions				.getSelectAllAction()));	}}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?