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); } } }
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); } } }
newCaret.addChangeListener(new ChangeListener() {
caret.addChangeListener(caretL); caret.addChangeListener(caretL);
caret.addChangeListener(caretL); caret.addChangeListener(caretL);
add(new JScrollPane(right)); left.getCaret().addChangeListener(new ChangeListener() { @Override public void stateChanged(ChangeEvent e) {
right.getCaret().setSelectionVisible(true); left.getCaret().addChangeListener(new ChangeHandler(left, right)); right.getCaret().addChangeListener(new ChangeHandler(right, left));
right.setEditable(false); left.getCaret().addChangeListener(new ChangeHandler(left, right)); right.getCaret().addChangeListener(new ChangeHandler(right, left));
caret.addChangeListener(this); this.caretTimer = new Timer(500, this); caretTimer.setRepeats(false);
/** 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); }
/** * 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); }