Example usage for javax.swing.text Segment toString

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

Introduction

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

Prototype

public String toString() 

Source Link

Document

Converts a segment into a String.

Usage

From source file:Console.java

void returnPressed() {
    Document doc = getDocument();
    int len = doc.getLength();
    Segment segment = new Segment();
    try {//from  ww  w .  ja v  a  2 s.  c om
        synchronized (doc) {
            doc.getText(outputMark, len - outputMark, segment);
        }
    } catch (javax.swing.text.BadLocationException ignored) {
        ignored.printStackTrace();
    }
    if (segment.count > 0) {
        history.addElement(segment.toString());
    }
    historyIndex = history.size();
    inPipe.write(segment.array, segment.offset, segment.count);
    append("\n");
    synchronized (doc) {
        outputMark = doc.getLength();
    }
    inPipe.write("\n");
    inPipe.flush();
    console1.flush();
}