Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import javax.swing.JTextArea;
import javax.swing.event.CaretEvent;
import javax.swing.event.CaretListener;
import javax.swing.text.JTextComponent;

public class Main {
    public static void main(String[] argv) {
        JTextComponent textComp = new JTextArea();
        textComp.addCaretListener(new CaretListener() {
            public void caretUpdate(CaretEvent e) {

                int dot = e.getDot();
                System.out.println("dot is the caret position:" + dot);

                int mark = e.getMark();
                System.out.println("mark is the non-caret end of the selection: " + mark);
            }
        });
    }
}