The Java Developers Almanac 1.4


Order this book from Amazon.

   
Home > List of Packages > javax.swing.text  [49 examples] > Styles  [9 examples]

e1009. Listing the Styles Associated with a JTextPane

This example lists the styles that have been associated with a text pane.
    DefaultStyledDocument doc = (DefaultStyledDocument)textPane.getDocument();
    Enumeration enum = doc.getStyleNames();
    while (enum.hasMoreElements()) {
        String styleName = (String)enum.nextElement();
    
        // Get style object
        Style style = doc.getStyle(styleName);
    }

 Related Examples
e1006. Highlighting Words in a JTextComponent
e1007. Setting the Font and Color of Text in a JTextPane Using Styles
e1008. Sharing Styles Between JTextPanes
e1010. Listing the Attributes in a Style
e1011. Using a Popup to Apply Styles to a JTextPane
e1012. Retaining the Logical Style When Setting a New Paragraph Style
e1013. Automatically Updating Styled Text When a Style Is Updated
e1014. Determining If a Style Attribute Applies to a Character or the Paragraph

See also: Actions and Key Bindings    Caret and Selection    Events    JEditorPane    JFormattedTextField    JTextArea    JTextComponent    JTextField    JTextPane   


© 2002 Addison-Wesley.