package guiTest;
import java.util.UUID;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import javax.swing.text.Segment;
public class MyDocument extends PlainDocument{
/**
*
*/
private static final long serialVersionUID = 7224102265305934163L;
private String string;
MyDocument(){
try {
int offset = 0;
int x = 0;
for (int i = 0; i < 1024; i++) {
string = UUID.randomUUID().toString() + "\n";
if ((string != null) && (x < 10)) {
x++;
}
insertString(offset, string, null);
offset += string.length();
}
} catch (BadLocationException e) {
e.printStackTrace();
}
}
@Override
public String getText(int offset, int length) throws BadLocationException {
// TODO Auto-generated method stub
System.out.println(String.format("getText: Offset %d / Length: %d",
offset, length));
return super.getText(offset, length);
}
@Override
public void getText(int offset, int length, Segment txt)
throws BadLocationException {
// TODO Auto-generated method stub
System.out.println(String.format(
"getTextWithSegment: Offset %d / Length: %d", offset, length));
super.getText(offset, length, txt);
}
@Override
public int getLength() {
// TODO Auto-generated method stub
int lenght = super.getLength();
System.out.println("getLenght:" + lenght);
return lenght;
}
}