Example usage for javax.swing.text JTextComponent validate

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

Introduction

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

Prototype

public void validate() 

Source Link

Document

Validates this container and all of its subcomponents.

Usage

From source file:Main.java

public static void refreshJTextComponent(JTextComponent textComponent) {
    // borrowed from metaphase editor
    int pos = textComponent.getCaretPosition();
    textComponent.setText(textComponent.getText());
    textComponent.validate();
    try {/*from w ww  .j  ava2 s  . c  om*/
        textComponent.setCaretPosition(pos);
    } catch (IllegalArgumentException e) {
        // swallow the exception
        // seems like a bug in the JTextPane component
        // only happens occasionally when pasting text at the end of a document
        System.err.println(e.getMessage());
    }
}