当前位置: 首页>>代码示例>>Java>>正文


Java Keymap.setDefaultAction方法代码示例

本文整理汇总了Java中javax.swing.text.Keymap.setDefaultAction方法的典型用法代码示例。如果您正苦于以下问题:Java Keymap.setDefaultAction方法的具体用法?Java Keymap.setDefaultAction怎么用?Java Keymap.setDefaultAction使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.text.Keymap的用法示例。


在下文中一共展示了Keymap.setDefaultAction方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: createBackup

import javax.swing.text.Keymap; //导入方法依赖的package包/类
private static void createBackup() {
    Keymap oldBackup = JTextComponent.getKeymap(EmacsKeyBindings.JTCS[0].getClass().getName());
    if (oldBackup != null) {
        // if there is already a backup, do not create a new backup
        return;
    }

    for (JTextComponent jtc : EmacsKeyBindings.JTCS) {
        Keymap orig = jtc.getKeymap();
        Keymap backup = JTextComponent.addKeymap
                (jtc.getClass().getName(), null);
        Action[] bound = orig.getBoundActions();
        for (Action aBound : bound) {
            KeyStroke[] strokes = orig.getKeyStrokesForAction(aBound);
            for (KeyStroke stroke : strokes) {
                backup.addActionForKeyStroke(stroke, aBound);
            }
        }
        backup.setDefaultAction(orig.getDefaultAction());
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:22,代码来源:EmacsKeyBindings.java

示例2: unload

import javax.swing.text.Keymap; //导入方法依赖的package包/类
/**
 * Restores the original keybindings for the concrete subclasses of
 * {@link JTextComponent}.
 */
public static void unload() {
    for (int i = 0; i < EmacsKeyBindings.JTCS.length; i++) {
        Keymap backup = JTextComponent.getKeymap
                (EmacsKeyBindings.JTCS[i].getClass().getName());

        if (backup != null) {
            Keymap current = EmacsKeyBindings.JTCS[i].getKeymap();
            current.removeBindings();

            Action[] bound = backup.getBoundActions();
            for (Action aBound : bound) {
                KeyStroke[] strokes =
                        backup.getKeyStrokesForAction(bound[i]);
                for (KeyStroke stroke : strokes) {
                    current.addActionForKeyStroke(stroke, aBound);
                }
            }
            current.setDefaultAction(backup.getDefaultAction());
        }
    }
}
 
开发者ID:JabRef,项目名称:jabref,代码行数:26,代码来源:EmacsKeyBindings.java

示例3: load

import javax.swing.text.Keymap; //导入方法依赖的package包/类
/***
 * Loads the emacs keybindings for all common <code>JTextComponent</code>s.
 * 
 * The shared keymap instances of the concrete subclasses of
 * {@link JTextComponent} are fed with the keybindings.
 * 
 * The original keybindings are stored in a backup array.
 */
public static void load() {
	JTextComponent[] jtcs = new JTextComponent[] { new JTextArea(),
			new JTextPane(), new JTextField(), new JEditorPane(), };

	for (int i = 0; i < jtcs.length; i++) {
		Keymap orig = jtcs[i].getKeymap();
		Keymap backup = JTextComponent.addKeymap(jtcs[i].getClass()
				.getName(), null);

		Action[] bound = orig.getBoundActions();
		for (int j = 0; j < bound.length; j++) {
			KeyStroke[] strokes = orig.getKeyStrokesForAction(bound[j]);
			for (int k = 0; k < strokes.length; k++) {
				backup.addActionForKeyStroke(strokes[k], bound[j]);
			}
		}

		backup.setDefaultAction(orig.getDefaultAction());
	}

	loadEmacsKeyBindings();
}
 
开发者ID:jpverkamp,项目名称:wombat-ide,代码行数:31,代码来源:EmacsKeyBindings.java

示例4: unload

import javax.swing.text.Keymap; //导入方法依赖的package包/类
/***
 * Restores the original keybindings for the concrete subclasses of
 * {@link JTextComponent}.
 * 
 */
public static void unload() {
	JTextComponent[] jtcs = new JTextComponent[] { new JTextArea(),
			new JTextPane(), new JTextField(), new JEditorPane(), };

	for (int i = 0; i < jtcs.length; i++) {
		Keymap backup = JTextComponent.getKeymap(jtcs[i].getClass()
				.getName());

		if (backup != null) {
			Keymap current = jtcs[i].getKeymap();
			current.removeBindings();

			Action[] bound = backup.getBoundActions();
			for (int j = 0; j < bound.length; j++) {
				KeyStroke[] strokes = backup
						.getKeyStrokesForAction(bound[i]);
				for (int k = 0; k < strokes.length; k++) {
					current.addActionForKeyStroke(strokes[k], bound[j]);
				}
			}
			current.setDefaultAction(backup.getDefaultAction());
		}
	}
}
 
开发者ID:jpverkamp,项目名称:wombat-ide,代码行数:30,代码来源:EmacsKeyBindings.java

示例5: OutlinerCellRendererImpl

import javax.swing.text.Keymap; //导入方法依赖的package包/类
public OutlinerCellRendererImpl() {
	super();
	
	// Add Actions to TextArea
	setupMaps(this.getInputMap(), this.getActionMap());
	setupMaps(this.button.getInputMap(), this.button.getActionMap());
	
	Keymap keymap = this.getKeymap();
	keymap.setDefaultAction(defaultAction);
	
	
	// Settings
	setFont(font);
	setCursor(cursor);
	setCaretColor(Preferences.getPreferenceColor(Preferences.SELECTED_CHILD_COLOR).cur);
	setMargin(marginInsets);
	setSelectionColor(Preferences.getPreferenceColor(Preferences.TEXTAREA_FOREGROUND_COLOR).cur);
	setSelectedTextColor(Preferences.getPreferenceColor(Preferences.TEXTAREA_BACKGROUND_COLOR).cur);
	setLineWrap(true);
	
	if (Preferences.getPreferenceString(Preferences.LINE_WRAP).cur.equals(Preferences.TXT_CHARACTERS)) {
		setWrapStyleWord(false);
	} else {
		setWrapStyleWord(true);
	}
	
	//setVisible(false);
}
 
开发者ID:hashrock,项目名称:JavaOutlineEditor,代码行数:29,代码来源:OutlinerCellRendererImpl.java


注:本文中的javax.swing.text.Keymap.setDefaultAction方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。