Search in sources :

Example 1 with ParagraphListener

use of org.apache.pivot.wtk.TextArea.ParagraphListener 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);
}
Also used : Window(org.apache.pivot.wtk.Window) TextArea(org.apache.pivot.wtk.TextArea) TextAreaContentListener(org.apache.pivot.wtk.TextAreaContentListener) ParagraphListener(org.apache.pivot.wtk.TextArea.ParagraphListener) Paragraph(org.apache.pivot.wtk.TextArea.Paragraph)

Aggregations

TextArea (org.apache.pivot.wtk.TextArea)1 Paragraph (org.apache.pivot.wtk.TextArea.Paragraph)1 ParagraphListener (org.apache.pivot.wtk.TextArea.ParagraphListener)1 TextAreaContentListener (org.apache.pivot.wtk.TextAreaContentListener)1 Window (org.apache.pivot.wtk.Window)1