editorkeyboardhandler.java
来自「经典的java图像处理程序源码」· Java 代码 · 共 77 行
JAVA
77 行
/** * $Id: EditorKeyboardHandler.java,v 1.1 2009/02/22 11:01:18 gaudenz Exp $ * Copyright (c) 2008, Gaudenz Alder */package com.mxgraph.swing.examples.editor;import javax.swing.ActionMap;import javax.swing.InputMap;import javax.swing.JComponent;import javax.swing.KeyStroke;import com.mxgraph.swing.mxGraphComponent;import com.mxgraph.swing.handler.mxKeyboardHandler;import com.mxgraph.swing.util.mxGraphActions;/** * @author Administrator * */public class EditorKeyboardHandler extends mxKeyboardHandler{ /** * * @param graphComponent */ public EditorKeyboardHandler(mxGraphComponent graphComponent) { super(graphComponent); } /** * Return JTree's input map. */ protected InputMap getInputMap(int condition) { InputMap map = super.getInputMap(condition); if (condition == JComponent.WHEN_FOCUSED && map != null) { map.put(KeyStroke.getKeyStroke("control S"), "save"); map.put(KeyStroke.getKeyStroke("control shift S"), "saveAs"); map.put(KeyStroke.getKeyStroke("control N"), "new"); map.put(KeyStroke.getKeyStroke("control O"), "open"); map.put(KeyStroke.getKeyStroke("control Z"), "undo"); map.put(KeyStroke.getKeyStroke("control Y"), "redo"); map .put(KeyStroke.getKeyStroke("control shift V"), "selectVertices"); map.put(KeyStroke.getKeyStroke("control shift E"), "selectEdges"); } return map; } /** * Return the mapping between JTree's input map and JGraph's actions. */ protected ActionMap createActionMap() { ActionMap map = super.createActionMap(); map.put("save", new EditorActions.SaveAction(false)); map.put("saveAs", new EditorActions.SaveAction(true)); map.put("new", new EditorActions.NewAction()); map.put("open", new EditorActions.OpenAction()); map.put("undo", new EditorActions.HistoryAction(true)); map.put("redo", new EditorActions.HistoryAction(false)); map.put("selectVertices", mxGraphActions.getSelectVerticesAction()); map.put("selectEdges", mxGraphActions.getSelectEdgesAction()); return map; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?