List of usage examples for javax.swing JTextPane getHighlighter
public Highlighter getHighlighter()
From source file:Main.java
public Main() { setSize(300, 200);/*from w ww . j av a 2s . co m*/ setDefaultCloseOperation(EXIT_ON_CLOSE); final JTextPane textPane = new JTextPane(); add(textPane); textPane.addCaretListener(new CaretListener() { public void caretUpdate(CaretEvent e) { Highlight[] h = textPane.getHighlighter().getHighlights(); for (int i = 0; i < h.length; i++) { System.out.println(h[i].getStartOffset()); System.out.println(h[i].getEndOffset()); } } }); }