javax.swing.text.Caret.addChangeListener()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(4.4k)|赞(0)|评价(0)|浏览(122)

本文整理了Java中javax.swing.text.Caret.addChangeListener()方法的一些代码示例,展示了Caret.addChangeListener()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Caret.addChangeListener()方法的具体详情如下:
包路径:javax.swing.text.Caret
类名称:Caret
方法名:addChangeListener

Caret.addChangeListener介绍

暂无

代码示例

代码示例来源:origin: net.java.abeille/abeille

public void propertyChange(PropertyChangeEvent evt) {
  String propName = evt.getPropertyName();
  if ("document".equals(propName)) {
    BaseDocument oldDoc = (evt.getOldValue() instanceof BaseDocument) ? (BaseDocument) evt.getOldValue() : null;
    BaseDocument newDoc = (evt.getNewValue() instanceof BaseDocument) ? (BaseDocument) evt.getNewValue() : null;
    modelChanged(oldDoc, newDoc);
  }
  else if ("margin".equals(propName)) { // NOI18N
    updateTextMargin();
  }
  else if ("caret".equals(propName)) { // NOI18N
    if (evt.getOldValue() instanceof Caret) {
      ((Caret) evt.getOldValue()).removeChangeListener(this);
    }
    if (evt.getNewValue() instanceof Caret) {
      ((Caret) evt.getNewValue()).addChangeListener(this);
    }
  }
  else if ("enabled".equals(propName)) { // NOI18N
    if (!component.isEnabled()) {
      component.getCaret().setVisible(false);
    }
  }
}

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

public void propertyChange(PropertyChangeEvent evt) {
  String propName = evt.getPropertyName();
  if ("document".equals(propName)) { // NOI18N
    BaseDocument oldDoc = (evt.getOldValue() instanceof BaseDocument)
               ? (BaseDocument)evt.getOldValue() : null;
    BaseDocument newDoc = (evt.getNewValue() instanceof BaseDocument)
               ? (BaseDocument)evt.getNewValue() : null;
    modelChanged(oldDoc, newDoc);
  } else if ("margin".equals(propName)) { // NOI18N
    updateTextMargin();
  } else if ("caret".equals(propName)) { // NOI18N
    if (evt.getOldValue() instanceof Caret) {
      ((Caret)evt.getOldValue()).removeChangeListener(this);
    }
    if (evt.getNewValue() instanceof Caret) {
      ((Caret)evt.getNewValue()).addChangeListener(this);
    }
  } else if ("enabled".equals(propName)) { // NOI18N
    if (!component.isEnabled()) {
      component.getCaret().setVisible(false);
    }
  }
}

代码示例来源:origin: stackoverflow.com

newCaret.addChangeListener(new ChangeListener() {

代码示例来源:origin: net.java.abeille/abeille

caret.addChangeListener(caretL);
caret.addChangeListener(caretL);

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

caret.addChangeListener(caretL);
caret.addChangeListener(caretL);

代码示例来源:origin: stackoverflow.com

add(new JScrollPane(right));
left.getCaret().addChangeListener(new ChangeListener() {
  @Override
  public void stateChanged(ChangeEvent e) {

代码示例来源:origin: stackoverflow.com

right.getCaret().setSelectionVisible(true);
left.getCaret().addChangeListener(new ChangeHandler(left, right));
right.getCaret().addChangeListener(new ChangeHandler(right, left));

代码示例来源:origin: stackoverflow.com

right.setEditable(false);
left.getCaret().addChangeListener(new ChangeHandler(left, right));
right.getCaret().addChangeListener(new ChangeHandler(right, left));

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-mercurial

caret.addChangeListener(this);
this.caretTimer = new Timer(500, this);
caretTimer.setRepeats(false);

代码示例来源:origin: net.sf.squirrel-sql.thirdparty-non-maven/org-netbeans-modules-editor-lib

/** Called when the <tt>BaseTextUI</tt> is being installed
* into the component.
*/
protected void installUI(JTextComponent c) {
  synchronized (getComponentLock()) {
    this.component = c;
    putProperty(COMPONENT_PROPERTY, c);
    // listen on component
    component.addPropertyChangeListener(this);
    component.addFocusListener(focusL);
    // listen on caret
    Caret caret = component.getCaret();
    if (caret != null) {
      caret.addChangeListener(this);
    }
    BaseDocument doc = getDocument();
    if (doc != null) {
      modelChanged(null, doc);
    }
  }
  // Make sure all the things depending on non-null component will be updated
  settingsChange(null);
  
  // fix for issue #16352
  getDefaultColoring().apply(component);
}

代码示例来源:origin: net.java.abeille/abeille

/**
 * Called when the <tt>BaseTextUI</tt> is being installed into the
 * component.
 */
protected void installUI(JTextComponent c) {
  synchronized (getComponentLock()) {
    this.component = c;
    putProperty(COMPONENT_PROPERTY, c);
    // listen on component
    component.addPropertyChangeListener(this);
    component.addFocusListener(focusL);
    // listen on caret
    Caret caret = component.getCaret();
    if (caret != null) {
      caret.addChangeListener(this);
    }
    BaseDocument doc = getDocument();
    if (doc != null) {
      modelChanged(null, doc);
    }
  }
  // Make sure all the things depending on non-null component will be
  // updated
  settingsChange(null);
  // fix for issue #16352
  getDefaultColoring().apply(component);
}

相关文章