Example usage for javax.swing.text Segment next

List of usage examples for javax.swing.text Segment next

Introduction

In this page you can find the example usage for javax.swing.text Segment next.

Prototype

public char next() 

Source Link

Document

Increments the iterator's index by one and returns the character at the new index.

Usage

From source file:LiveParenMatcher.java

public void insertUpdate_3(DocumentEvent de) {
    Document doc = de.getDocument();
    int offset = de.getOffset();
    int length = de.getLength();
    Segment seg = new Segment();
    try {//from w w w  . j  av a 2  s.c  om
        doc.getText(offset, length, seg); // text placed in Segment
    } catch (BadLocationException ble) {
    }

    // iterate through the Segment
    for (char ch = seg.first(); ch != seg.DONE; ch = seg.next())
        if (ch == '(' || ch == '[' || ch == '{' || ch == ')' || ch == ']' || ch == '}') {
            SwingUtilities.invokeLater(this); // will call run()
            return; // no need to check further
        }
}