Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 801061
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T23:23:07+00:00 2026-05-14T23:23:07+00:00

I’ve been reading the javadocs trying to grasp around the swing Document API but

  • 0

I’ve been reading the javadocs trying to grasp around the swing Document API but I cant get something sensible out of it because there’s so many classes: Document, StyledDocument, AbstractDocument, DefaultStyledDocument, PlainDocument, HTMLDocument, and someone mentioned DocumentFilter. This question is more on a general basis so can someone give an overview of the differences between the implementations and when the different interfaces and abstracts are for?

For my specific case what I want to achieve is a data structure that will:

  • hold three lines of text only. And
  • attributes must not be per line or document. I will have a couple of thousand of these in some other structure so
  • overhead is important.

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T23:23:08+00:00Added an answer on May 14, 2026 at 11:23 pm

    All of the Document classes you list have the same base functionality and each expands based on a niche that needs to be filled. Really, it’s just a matter of realizing what you need to do and use the appropriate document type. For instance, if I am editing an HTML file, then I would use the HTMLDocument class.

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

    Document

    The Document interface represents the
    entire HTML or XML document.
    Conceptually, it is the root of the
    document tree, and provides the
    primary access to the document’s data.

    This is the interface that all other Document types will inherit from. It provides the contract for all other Document types to follow.

    AbstractDocument

    This class implements a locking
    mechanism for the document it allows
    multiple readers or one writer, and
    writers must wait until all observers
    of the document have been notified of
    a previous change before beginning
    another mutation to the document.

    This class allows you to work with different types of documents and uses a very lose ruleset. This class is more difficult to implement because it is so generic.

    StyledDocument

    Another interface that provides a contract for all styled documents. DefaultStyledDocument implements this interface, so we’ll get to that next.

    DefaultStyledDocument

    A document that can be marked up with
    character and paragraph styles in a
    manner similar to the Rich Text
    Format. The element structure for this
    document represents style crossings
    for style runs. These style runs are
    mapped into a paragraph element
    structure (which may reside in some
    other structure). The style runs break
    at paragraph boundaries since logical
    styles are assigned to paragraph
    boundaries.

    DefaultStyledDocument allows you to place special characters within the document to help with formatting etc… Think Microsoft Word when you think about DefaultStyledDocument.

    DocumentFilter

    hen a Document containing a
    DocumentFilter is modified (either
    through insert or remove), it forwards
    the appropriate method invocation to
    the DocumentFilter.

    This is an extremely useful class that “listens” for events to occur against your document (i.e. modification) and will perform an action when each event occurs.

    PlainDocument

    implements AbstractDocument and does not contain any kind of formatting special characters (Think notepad vs. Word). You should use this when you just want to store text (log file, etc.)

    HTMLDocument

    A document that models HTML. The
    purpose of this model is to support
    both browsing and editing.

    HTMLDocument should be used when you are creating/modifying documents that contain HTML code and are intended to be viewed in a browser.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I am trying to loop through a bunch of documents I have to put
I'm making a simple page using Google Maps API 3. My first. One marker
I'm looking for suggestions for debugging... If you view this site in Firefox or
Does anyone know how can I replace this 2 symbol below from the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.