use of org.apache.pivot.wtk.TextAreaContentListener in project pivot by apache.
the class Pivot841 method startup.
@Override
public void startup(Display display, Map<String, String> properties) throws Exception {
TextArea textArea = new TextArea();
textArea.setText("abcxyz");
final ParagraphListener paragraphListener = new ParagraphListener.Adapter() {
@Override
public void textInserted(Paragraph paragraph, int index, int count) {
System.out.println("Text inserted\n\tparagraph content: '" + paragraph.getCharacters() + "" + "'\n\tindex: " + index + "\n\tcount: " + count);
}
@Override
public void textRemoved(Paragraph paragraph, int index, int count) {
System.out.println("Text removed\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index + "\n\tcount: " + count);
}
};
textArea.getParagraphs().get(0).getParagraphListeners().add(paragraphListener);
textArea.getTextAreaContentListeners().add(new TextAreaContentListener() {
@Override
public void paragraphInserted(TextArea textAreaArgument, int index) {
Paragraph paragraph = textAreaArgument.getParagraphs().get(index);
System.out.println("Paragraph inserted\n\tparagraph content: '" + paragraph.getCharacters() + "'\n\tindex: " + index);
paragraph.getParagraphListeners().add(paragraphListener);
}
});
Window window = new Window(textArea);
window.open(display);
}
Aggregations