Example usage for javax.swing.text JTextComponent setText

List of usage examples for javax.swing.text JTextComponent setText

Introduction

In this page you can find the example usage for javax.swing.text JTextComponent setText.

Prototype

@BeanProperty(bound = false, description = "the text of this component")
public void setText(String t) 

Source Link

Document

Sets the text of this TextComponent to the specified text.

Usage

From source file:org.nuclos.client.ui.collect.component.AbstractCollectableComponent.java

/**
 * sets the given condition in this component, using text comp as this component's text component.
 * @param atomiccond//from  w  w  w .j a va2s.  com
 * @param textcomp
 * @precondition isViewLocked()
 * @precondition canDisplay(atomiccond)
 */
protected final void modelToView(AtomicCollectableSearchCondition atomiccond, JTextComponent textcomp) {
    if (!canDisplay(atomiccond)) {
        throw new IllegalArgumentException("Condition cannot be displayed: " + LangUtils.toString(atomiccond));
    }
    final ComparisonOperator compop = (atomiccond == null) ? ComparisonOperator.NONE
            : atomiccond.getComparisonOperator();

    setComparisonOperator(compop);

    if (atomiccond instanceof CollectableComparisonWithOtherField) {
        assert canDisplayComparisonWithOtherField();
        final CollectableComparisonWithOtherField comparisonwf = (CollectableComparisonWithOtherField) atomiccond;
        setWithComparison(comparisonwf.getOtherField());
    } else if (atomiccond instanceof CollectableComparisonWithParameter) {
        assert canDisplayComparisonWithOtherField();
        final CollectableComparisonWithParameter comparisonwp = (CollectableComparisonWithParameter) atomiccond;
        setWithComparison(comparisonwp.getParameter());
    } else {
        resetWithComparison();
    }

    final String sText;
    if (compop.getOperandCount() < 2) {
        sText = null;
    } else {
        assert atomiccond != null;
        sText = atomiccond.getComparandAsString();
    }

    assert isViewLocked();
    textcomp.setText(sText);
}

From source file:tufts.vue.ui.InspectorPane.java

private void loadText(JTextComponent c, String text) {
    String hasText = c.getText();
    // This prevents flashing where fields of
    // length greater the the visible area do
    // a flash-scroll when setting the text, even
    // if it's the same as what's there.
    if (hasText != text && !hasText.equals(text))
        c.setText(text);
}