Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Editable Text + Highlightable Text

843807Jun 16 2010 — edited Jun 17 2010
I want to have three functions with dealing with a block of Text in my program.

(1) I want to highlight and make certain a certain row is highlighted at which the user cannot edit the text. The highlighting process is used by the GUI not the user.
(2) I want to a allow the text to be allowed at my will.
(3) When editing is allowed, I only want certain lines to be editable.
Also I won't be using the wrap around feature.

So far I have looked at JList and JTextArea

JTextArea
Pro's:
I can allow the user to edit the code freely.

Con's:
I don't know how to prevent editing certain rows or highlight them.

JList
Pro's:
I can highlight certain rows.
I'm certain a can change individual lines.

Con's:
I can't imagine it being so freely editable.

I'm leaning more towards using JList but I am not sure how to go about adding and removing certain rows. Otherwise, I can make sure which lines are not changed. It would be alright if the user had to click a row to edit it but I also want to add and remove. The API doesn't seem to support that kind of operation. I'm just wondering if anyone out there has any ideas on how to implement this.

Thanks (@)(@)
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 15 2010
Added on Jun 16 2010
2 comments
148 views