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 7024777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:53:11+00:00 2026-05-27T23:53:11+00:00

I have designed an html document editor and I wanted some help in resolving

  • 0

I have designed an html document editor and I wanted some help in resolving a design problem in it. The problem is as follows –

The document editor consists of a surface (JFrame) and a menu bar. Inside the surface I have three panels – a tool panel, text panel and status panel (which are all extensions of JPanel). The text panel has the customized text pane (extension of JTextPane). Now the problem is that – there are lots of scenarios where the menus and the widgets items on the tool panel need access to the underlying document model of the JTextPane. E.g. to implement list/paragraph dragging functionality, the ruler needs to know the position of the caret inside the document model, so that I can mark the paragraph whose left inset I need to increase.

The way I have organized my design right now is that – surface is a singleton, so to access the html document model inside the JTextPane you need to code your way through the following maze –

Give me surface -> go to text panel -> go to text pane -> go to document of the text pane

Another alternative to make the reference of the document inside the text pane static, so that it can be accessed directly.

TextPane.getTextDocument ()

Also the html document inside the Text Pane I am using is not customized right now. So I am just using the default HTMLDocument returned by the text pane. Though in future I may have to replace it with a more customized extension of HTMLDocument (e.g. to implement cusom tags)

I am somewhat of a design novice. Can some design guru throw some light/insight into this?

  • 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-27T23:53:11+00:00Added an answer on May 27, 2026 at 11:53 pm

    I think if you get 10 responses you’ll get 11 answers. 🙂

    First, there is no need for a Singleton. In this scenario, it’s just a way of cheating with a global variable. And what happens when you want to have two or three text documents open?

    Do your menus have ready access to the tool panel? Since toolpanel is a sibling of the textpanel, and in a 1-1 relationship (I think?) it is somewhat “reasonable” for toolpanel to know about textdocument (have a link it) and a convenience method, getTextDocument(). And it seems reasonable for your widgets to know about their immediate parent, the tool panel.

    That would be my way of approaching the problem – what links between objects “make sense”. You want as little coupling as possible, but there are places where you do need coupling. Maybe I have misunderstood your problem, or maybe you think a lot differently than me, in which case you should do it another way. Also, you are making a best guess as to how your code might evolve in the future. Good luck with that! 🙂

    One big question for any solution – does the text document change? (e.g., is there a File->New menu or a File->Open menu?). If so, that needs to be considered. In my proposal, the JFrame, on a File->Open, would create the text document and then change the link to it in the ToolBar.

    p.s. MVC purists – please add appropriate models and controllers! I just talked about the graphical components to keep things simpler…

    p.p.s. Examples of “thinking ahead” for reasonable enhancements

    1. Would this handle multiple JFrames open at once? Yes.
    2. Would this handle a single JFrame, but with multiple documents (say, a tabbed interface for the text document)? Almost. The method has to be a little smarter to know which of the many documents is active, but you can easily imagine doing that.
    3. How about when I need to hold a lot more info about the dicument, like the name (so Save gives a good default), last time saved, is it “dirty”, is it HTML or XHTML or whatever… At this point, you’ll probably want to add one more model layer. But you can sortof imagine, with one more layer of indirection (one more link) this being o.k. So it depends on how close you are to implementing #3 how you want to design.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some pages designed by someone else as simple HTML that I need
I have designed a custom section handler before but I'm faced with a problem
I have designed a HTML for with the tabindex set to the fieds. There
I have designed a custom calendar using html and jQuery. I want to highlight
I have a html table which consists of columns for days, and rows for
Let's say that I have two html pages that are identically designed, but have
I have designed specified some CSS style for general hyperlinks. I want to specify
I have designed a website that consists of the body, a container to hold
I have designed a layout and i find some gaps in the stacking of
I have a big problem with the layout of a webpage designed for iPad

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.