java.awt.event.TextEvent Java Examples

The following examples show how to use java.awt.event.TextEvent. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LWTextAreaPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #2
Source File: XTextFieldPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #3
Source File: LWTextComponentPeer.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #4
Source File: LWTextComponentPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #5
Source File: LWTextAreaPeer.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #6
Source File: XTextFieldPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #7
Source File: LWTextComponentPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #8
Source File: LWTextComponentPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #9
Source File: LWTextAreaPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getDelegate().getView().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #10
Source File: GenericLoadParseQueryXML.java    From SPIM_Registration with GNU General Public License v2.0 6 votes vote down vote up
protected void addListeners( final GenericDialog gd, final TextField tf, final Label label1, final Label label2  )
{
	final GenericLoadParseQueryXML< ?,?,?,?,?,? > lpq = this;
	
	// using TextListener instead
	tf.addTextListener( new TextListener()
	{	
		@Override
		public void textValueChanged( final TextEvent t )
		{
			if ( t.getID() == TextEvent.TEXT_VALUE_CHANGED )
			{
				final String xmlFilename = tf.getText();
				
				// try parsing if it ends with XML
				tryParsing( xmlFilename, false );
				
				label1.setText( lpq.message1 );
				label2.setText( lpq.message2 );
				label1.setForeground( lpq.color );
				label2.setForeground( lpq.color );
			}
		}
	});
}
 
Example #11
Source File: XTextFieldPeer.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #12
Source File: LWTextAreaPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #13
Source File: LWTextAreaPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getDelegate().getView().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #14
Source File: XTextFieldPeer.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #15
Source File: LWTextAreaPeer.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #16
Source File: LWTextAreaPeer.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #17
Source File: XTextFieldPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #18
Source File: LWTextComponentPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #19
Source File: LWTextComponentPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #20
Source File: LWTextComponentPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #21
Source File: LWTextAreaPeer.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #22
Source File: LWTextComponentPeer.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
@Override
public final void setText(final String text) {
    synchronized (getDelegateLock()) {
        // JTextArea.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.setText() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getTextComponent().setText(text);
        revalidate();
        if (firstChangeSkipped) {
            postEvent(new TextEvent(getTarget(),
                                    TextEvent.TEXT_VALUE_CHANGED));
        }
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #23
Source File: LWTextAreaPeer.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void replaceRange(final String text, final int start,
                         final int end) {
    synchronized (getDelegateLock()) {
        // JTextArea.replaceRange() posts two different events.
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextArea.replaceRange() is called.
        final Document document = getTextComponent().getDocument();
        document.removeDocumentListener(this);
        getDelegate().getView().replaceRange(text, start, end);
        revalidate();
        postEvent(new TextEvent(getTarget(), TextEvent.TEXT_VALUE_CHANGED));
        document.addDocumentListener(this);
    }
    repaintPeer();
}
 
Example #24
Source File: XTextFieldPeer.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #25
Source File: XTextFieldPeer.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
private void setXAWTTextField(String txt) {
    text = txt;
    if (xtext != null)  {
        // JTextField.setText() posts two different events (remove & insert).
        // Since we make no differences between text events,
        // the document listener has to be disabled while
        // JTextField.setText() is called.
        xtext.getDocument().removeDocumentListener(xtext);
        xtext.setText(txt);
        if (firstChangeSkipped) {
            postEvent(new TextEvent(target, TextEvent.TEXT_VALUE_CHANGED));
        }
        xtext.getDocument().addDocumentListener(xtext);
        xtext.setCaretPosition(0);
    }
}
 
Example #26
Source File: XTextFieldPeer.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void changedUpdate(DocumentEvent e) {
    if (xwin != null) {
        xwin.postEvent(new TextEvent(xwin.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
 
Example #27
Source File: XTextFieldPeer.java    From openjdk-8-source with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void insertUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
 
Example #28
Source File: IJDistribution.java    From thunderstorm with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void textValueChanged(TextEvent e) {
    if(!defaultNBins.equals(nBinsField.getText())) {
        checkbox.setState(false);
    }
    if(!defaultRange.equals(rangeField.getText())) {
        checkbox.setState(false);
    }
}
 
Example #29
Source File: XTextFieldPeer.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void insertUpdate(DocumentEvent e) {
    if (peer != null) {
        peer.postEvent(new TextEvent(peer.target,
                                     TextEvent.TEXT_VALUE_CHANGED));
    }
}
 
Example #30
Source File: AWTEvent.java    From Bytecoder with Apache License 2.0 5 votes vote down vote up
/**
 * Constructs an AWTEvent object with the specified source object and type.
 *
 * @param source the object where the event originated
 * @param id the event type
 */
public AWTEvent(Object source, int id) {
    super(source);
    this.id = id;
    switch(id) {
      case ActionEvent.ACTION_PERFORMED:
      case ItemEvent.ITEM_STATE_CHANGED:
      case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
      case TextEvent.TEXT_VALUE_CHANGED:
        consumed = true;
        break;
      default:
    }
}