/**
   * @param codep
   * @return
   */
  protected Caret installCaret(CodePoint codep) {
    // The caret will track the positions across the users' editings.
    final DefaultCaret place = new DefaultCaret();
    place.setUpdatePolicy(DefaultCaret.UPDATE_WHEN_ON_EDT);
    place.install(txtEditor);
    // remove mouse listeners from component, since we don't want the mouse to modify our caret
    txtEditor.removeMouseListener(place);
    txtEditor.removeMouseMotionListener(place);
    txtEditor.removeFocusListener(place);
    // configure visibility and set proper positions
    place.setVisible(false);
    place.setSelectionVisible(false);
    place.setDot(codep.y);
    place.moveDot(codep.x);
    log.info("Installed Caret for " + codep);
    place.addChangeListener(
        new ChangeListener() {

          @Override
          public void stateChanged(ChangeEvent e) {
            log.fine(e.getSource() + " at " + e.toString());
            // when the caret changes, update the display
            updateName();
          }
        });
    return place;
  }
示例#2
0
 /** {@inheritDoc} */
 public void setSelectionVisible(boolean vis) {
   super.setSelectionVisible(true);
 }