4 Replies - 2956 Views - Last Post: 07 October 2013 - 08:42 PM

#1 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 525
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Sophisticated Text Control?

Posted 07 October 2013 - 12:29 PM

Hello. I am searching for a way to provide a sophisticated text control in my application.

The requirements for this control are such that:
- Allow for multiple colors/fonts (rich edit essentially or microsoft word level)
- Allow for edit to one place to update everywhere (global find/replace while preserving the key)
- Allow for an event that will allow me to save the modification to a database

So, basically what I am doing is creating an application that will take biblical verses and load them into the document. Each verse may have any number of Strong's numbers associated with it. These are what are editable by the user. Once there is a modification done to a Strong's entry, then the rest of the document will update and the modification will save to the database keyed to that strong's number.

Let me give you an example:

1:1 In the beginning 7225 God 430 created 1254 8804 853 the heaven 8064 and 853 the earth 776

So, the user would click 7225 and type their note in. Upon completion of edit (which I think would be either escape or clicking elsewhere), this entry would save to the database. Furthermore, all entries of 7225 in the document will update with that modification.

Is there a control like this? Can I subclass an existing control that's pretty close to this? I'm really new to Java and I'm not sure what all is out there. I do recognize that this control will have to have custom work done to it but I am just not sure how much is already implemented.

I think that you can help me in a few different ways.

- Tell me of existing controls that implement some or all of this feature set.
- Suggest a better way to do this through the user input side of things (using a form with fields will not work out)
- Tell me of a way to make those linked numbers advanced such that they almost become their own control in the page. If that's the case, then looping just a collection would be much easier than searching text.

Thanks for the help. I will keep you posted on what I find.

Is This A Good Question/Topic? 0
  • +

Replies To: Sophisticated Text Control?

#2 macosxnerd101  Icon User is online

  • Self-Trained Economist
  • member icon




Reputation: 10178
  • View blog
  • Posts: 37,583
  • Joined: 27-December 08

Re: Sophisticated Text Control?

Posted 07 October 2013 - 12:38 PM

You may want to look into JEditorPane. It offers some HTML support. I would honestly just use the String replaceAll() (or perhaps manage a StringBuilder). You can then update in the database as you need.
Was This Post Helpful? 0
  • +
  • -

#3 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 525
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Sophisticated Text Control?

Posted 07 October 2013 - 12:47 PM

Yeah, I was looking at the JEditorPane.

Let me give an idea of the difficulty of find/replace though.

Let's say that I have the text such as:

This 123 is simply 44 an example of text 395

Then I modify my text a bit to say something like this:

This 123 some modification is simply 44 an example of text 395

What this does is goes an inserts everything where 123 is through a find/replace and that would be great.

Except what happens when I come across this:

That 123 some modification would be 54 interesting.

Here I realized that I need to change the text so I make my modification:

That 123 some modification, another change would be 54 interesting.

Now, I have to go through the document again and replace all occurrences of 123 with the update. I like the idea of the numbers+notes themselves to be a component all their own. Is this possible in Java? Can I add components to the text field much like you can with JPanels?
Was This Post Helpful? 0
  • +
  • -

#4 blackcompe  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1131
  • View blog
  • Posts: 2,484
  • Joined: 05-May 05

Re: Sophisticated Text Control?

Posted 07 October 2013 - 04:40 PM

MentalFloss: Why don't you use hyperlinks and allow the user to edit the content when a link is clicked using a HyperlinkListener.
Was This Post Helpful? 0
  • +
  • -

#5 MentalFloss  Icon User is offline

  • "ADDICTED"[2:5]
  • member icon

Reputation: 525
  • View blog
  • Posts: 1,397
  • Joined: 02-September 09

Re: Sophisticated Text Control?

Posted 07 October 2013 - 08:42 PM

I'm looking at the JTextPane right now which is a subclass of the JEditorPane. The coolest feature of it though is that you can embed components in it.

I haven't had a chance to explore the hyperlink idea yet. I have tried to find the document on it though and cannot seem to. I found the HyperlinkListener easily enough but I cannot find the hyperlink component. Thanks.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1