repaintListener = new DocumentListener() { public void changedUpdate(DocumentEvent ev) { repaint(); } public void insertUpdate(DocumentEvent ev) { repaint(); } public void removeUpdate(DocumentEvent ev) { repaint(); } };
  public JTextComponent()    {    repaintListener = new DocumentListener()      {	public void changedUpdate(DocumentEvent ev)	{	  repaint();	}	public void insertUpdate(DocumentEvent ev)	{	  repaint();	}	public void removeUpdate(DocumentEvent ev)	{	  repaint();	}      };    Keymap defkeymap = getKeymap(DEFAULT_KEYMAP);    boolean creatingKeymap = false;    if (defkeymap == null)      {        defkeymap = addKeymap(DEFAULT_KEYMAP, null);        defkeymap.setDefaultAction(new DefaultEditorKit.DefaultKeyTypedAction());        creatingKeymap = true;      }    setFocusable(true);        enableEvents(AWTEvent.KEY_EVENT_MASK);        updateUI();    // need to do this after updateUI()    if (creatingKeymap)      loadKeymap(defkeymap,                  new KeyBinding[] {                    new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0),                                  DefaultEditorKit.backwardAction),                   new KeyBinding(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0),                                  DefaultEditorKit.forwardAction),                   new KeyBinding(KeyStroke.getKeyStroke("typed \b"),                                  DefaultEditorKit.deletePrevCharAction),                   new KeyBinding(KeyStroke.getKeyStroke("typed \u007f"),                                  DefaultEditorKit.deleteNextCharAction)                                    },                 getActions());  }