Is it possible to make only a certain portion of a JTextArea uneditable? i.e. the rest of the textarea remains editable except a particular portion? Thanks.
Welcome to the Java Programming Forums
The professional, friendly Java community. 21,500 members and growing!
The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.
>> REGISTER NOW TO START POSTING
Members have full access to the forums. Advertisements are removed for registered users.
Is it possible to make only a certain portion of a JTextArea uneditable? i.e. the rest of the textarea remains editable except a particular portion? Thanks.
Yes, but it requires a bit of work.
See this article for an example where I made the first section of a JTextArea un-editable: http://www.javaprogrammingforums.com...component.html. Note that this isn't the only focus of that article, but if you scroll down to the section about Document Filters that will have what you want. Also, you'll need to do something about undo/redo. The simple answer is to disable undo/redo for your text area, but I think it's possible to filter out certain changes from being added to the undo/redo list.