本文整理汇总了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());
}
}
示例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());
}
}
}
示例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();
}
示例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());
}
}
}
示例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);
}