|
|
|
@ -1,20 +1,19 @@
|
|
|
|
|
package com.fr.design.gui.itextfield; |
|
|
|
|
|
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
import com.fr.design.event.GlobalNameListener; |
|
|
|
|
import com.fr.design.event.GlobalNameObserver; |
|
|
|
|
import com.fr.design.event.UIObserver; |
|
|
|
|
import com.fr.design.event.UIObserverListener; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import javax.swing.event.DocumentEvent; |
|
|
|
|
import javax.swing.event.DocumentListener; |
|
|
|
|
import javax.swing.text.DefaultEditorKit; |
|
|
|
|
import javax.swing.text.Document; |
|
|
|
|
|
|
|
|
|
import com.fr.design.event.GlobalNameListener; |
|
|
|
|
import com.fr.design.event.GlobalNameObserver; |
|
|
|
|
import com.fr.design.event.UIObserver; |
|
|
|
|
import com.fr.design.event.UIObserverListener; |
|
|
|
|
import com.fr.stable.Constants; |
|
|
|
|
import com.fr.design.utils.gui.GUICoreUtils; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.KeyEvent; |
|
|
|
|
|
|
|
|
|
import static com.fr.design.gui.syntax.ui.rtextarea.RTADefaultInputMap.DEFAULT_MODIFIER; |
|
|
|
|
|
|
|
|
@ -33,14 +32,21 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
|
|
|
|
|
public UITextField() { |
|
|
|
|
super(); |
|
|
|
|
InputMap inputMap = this.getInputMap(); |
|
|
|
|
inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), |
|
|
|
|
DefaultEditorKit.selectAllAction); |
|
|
|
|
inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), |
|
|
|
|
DefaultEditorKit.copyAction); |
|
|
|
|
inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), |
|
|
|
|
DefaultEditorKit.pasteAction); |
|
|
|
|
inputMap.getParent().put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), |
|
|
|
|
DefaultEditorKit.cutAction); |
|
|
|
|
while (inputMap.getParent() != null) { |
|
|
|
|
inputMap = inputMap.getParent(); |
|
|
|
|
} |
|
|
|
|
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER)) == null) { |
|
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_A, DEFAULT_MODIFIER), DefaultEditorKit.selectAllAction); |
|
|
|
|
} |
|
|
|
|
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER)) == null) { |
|
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_C, DEFAULT_MODIFIER), DefaultEditorKit.copyAction); |
|
|
|
|
} |
|
|
|
|
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER)) == null) { |
|
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_V, DEFAULT_MODIFIER), DefaultEditorKit.pasteAction); |
|
|
|
|
} |
|
|
|
|
if (inputMap.get(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER)) == null) { |
|
|
|
|
inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_X, DEFAULT_MODIFIER), DefaultEditorKit.cutAction); |
|
|
|
|
} |
|
|
|
|
initListener(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
@ -197,6 +203,7 @@ public class UITextField extends JTextField implements UIObserver, GlobalNameObs
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 主函数 |
|
|
|
|
* |
|
|
|
|
* @param args 参数 |
|
|
|
|
*/ |
|
|
|
|
public static void main(String... args) { |
|
|
|
|