Java examples for Swing:JTextPane
Listing the Styles Associated with a JTextPane
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[] args) throws Exception { JTextPane textPane = new JTextPane(); // w w w.ja va 2s . com DefaultStyledDocument doc = (DefaultStyledDocument)textPane.getDocument(); Enumeration e = doc.getStyleNames(); while (e.hasMoreElements()) { String styleName = (String)e.nextElement(); // Get style object Style style = doc.getStyle(styleName); } } }