Java tutorial
import java.util.Enumeration; import javax.swing.JTextPane; import javax.swing.text.DefaultStyledDocument; import javax.swing.text.Style; public class Main { public static void main(String[] argv) throws Exception { JTextPane textPane = new JTextPane(); DefaultStyledDocument doc = (DefaultStyledDocument) textPane.getDocument(); Enumeration e = doc.getStyleNames(); while (e.hasMoreElements()) { String styleName = (String) e.nextElement(); System.out.println(styleName); Style style = doc.getStyle(styleName); } } }