Customized Document Views

Java > Core SWING advanced programming > 2. USING JTEXTPANE

 

Chapter 2. USING JTEXTPANE

Topics in this Chapter

  • Attributes and Styles

  • Style Contexts

  • Paragraph and Character Attributes

  • Displaying Icons and Attributes in JTextPane

In the last chapter, you saw how the text components store the text that they draw and how to subclass the PlainDocument class used by JTextField to implement various forms of input validation. PlainDocument is a very simple text model that is sufficient for a component that uses a single font and two colors, but the Document interface itself also allows you to associate attributes with arbitrary ranges of content within the model, a facility that can be exploited by using the JTextPane and JEditorPane controls.

In this chapter, you'll see exactly what the attributes that you can store in the model represent and how the JTextPane allows you to specify the attributes that should be associated with an arbitrary run of text. With this knowledge, you'll be prepared for the next chapter, which looks at the View classes that determine how the attributes themselves are interpreted and translate them into font, color, and positioning information as the text component is rendered onto the screen. The material in this chapter also forms the groundwork for Chapter 4, which covers JEditorPane, the most powerful Swing text component and the one that makes full use of the features that you'll see in this chapter.

 

 



Core Swing
Core Swing: Advanced Programming
ISBN: 0130832928
EAN: 2147483647
Year: 1999
Pages: 55
Authors: Kim Topley

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net