The difference between document classes

I read the javadocs, trying to grab Swing Document API, but I can not get him something reasonable, because so many classes: Document, StyledDocument, AbstractDocument, DefaultStyledDocument, PlainDocument, HTMLDocument, and someone mentioned DocumentFilter. This question is more general, so can someone give an overview of the differences between implementations and when for different interfaces and theses?

In my specific case, I want to create a data structure that will be:

  • hold only three lines of text. AND
  • Attributes must not be in a line or document. I will have several thousand of them in some other structure, therefore
  • service data is important.

Anything I can use for this, or is it better to extend something? If so, then what?

+3
source share
2 answers

All of these document classes have the same basic functionality, and each of them extends based on a niche that needs to be filled. Actually, this is just a question of what you need to do and use the appropriate type of document. For example, if I edit an HTML file, then I would use the HTMLDocument class.

I have included a brief description of each of the document classes that you requested in your question below.

Document

The document interface is an entire HTML or XML document. Conceptually, this is the root of the document tree and primary access to document data.

This is the interface on which all other types of documents are inherited. It provides a contract for all other types of documents.

AbstractDocument

, , , .

. , .

StyledDocument

, . DefaultStyledDocument , .

DefaultStyledDocument

, , Rich Text . . ( ). , .

DefaultStyledDocument , .. Microsoft Word, DefaultStyledDocument.

DocumentFilter

hen , DocumentFilter ( ), DocumentFilter.

, "" , (.. ), .

PlainDocument

AbstractDocument - (Think notepad vs. Word). , ( ..).

HTMLDocument

, HTML. - , .

HTMLDocument , / , HTML-, .

+5

( , ). , , .

JTextField , .

JTextArea , . , .

JTextPane , , ..

, .

, , . , . 1k 40 , .

, JTextArea - , , , PlainDocument.

+1
source

Source: https://habr.com/ru/post/1746869/


All Articles