Java Swing - O Reilly public abstract Position createPosition(int (Web hosting providers)
Friday, August 31st, 2007Java Swing - O Reilly public abstract Position createPosition(int offs) throws BadLocationException Creates a Position object used to track the contents of the Document at the specified offset. Section 20.1.7, later in this chapter, contains an example showing how this might be used. public abstract Object getProperty(Object key) public abstract void putProperty(Object key, Object value) Retrieves and inserts (respectively) arbitrary properties associated with the document. These properties can be used to store things such as the document title, author, etc. public abstract void render(Runnable r) Executes the given Runnable, guaranteeing that the contents of the model will not be changed while the Runnable is running. The input Runnable may not modify the model. This method allows the Document to be painted without concerns about its contents changing during the painting process. It is called by the TextUI’s paint() method. 20.1.2 The Element Interface Element is an interface used to describe an arbitrary portion of a document. However, it’s important to realize that Elements do not actually contain a portion of the document, they just define a way of structuring it. Because of this, a Document may be described by multiple sets of Elements, each defining a different logical structure. Each Element is described by an AttributeSet, which defines things such as the font style or color used in the Element. Note that this means that all Document content described by a given Element will have the same set of attributes. Elements may contain other Elements, allowing a document to be described by an arbitrary tree structure. Figure 20.2 shows a purely hypothetical example of the structure of a series of Elements. In this diagram, there is a single “document” element made up of two “paragraph” elements, each of which is, in turn, made up of a pair of “sentence” elements. Finally, one of the sentences is further split into two more elements, one for a plain text area and the other for a section of bold text. Remember, this is only an example of how elements fit together; the element types here do not map directly to anything provided by Swing. Figure 20.2. Sample Element structure Another way to understand the concept of an Element is to look at mark-up languages such as HTML or XML. Documents defined by such mark-up languages can be easily represented using the - 612
Please visit our professional web hosting services to find out about cheap and reliable webhost service that will surely answer all your demands.