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.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 3 of 3

Thread: Making a portion of JTextArea uneditable

  1. #1
    Junior Member
    Join Date
    Dec 2010
    Thanked 0 Times in 0 Posts

    Default Making a portion of JTextArea uneditable

    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.

  2. #2
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Washington, DC
    My Mood
    Thanked 698 Times in 595 Posts

    Default Re: Making a portion of JTextArea uneditable

  3. #3
    Moderators helloworld922's Avatar
    Join Date
    Jun 2009
    Thanked 619 Times in 561 Posts
    Blog Entries

    Default Re: Making a portion of JTextArea uneditable

    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.

Similar Threads

  1. How To: Add line numbers to your JTextArea
    By Freaky Chris in forum Java Swing Tutorials
    Replies: 11
    Last Post: October 15th, 2013, 11:22 PM
  2. How to Read a Portion of a File in Java?
    By jazz2k8 in forum File I/O & Other I/O Streams
    Replies: 4
    Last Post: January 7th, 2013, 02:00 PM
  3. Expanding JTextArea
    By The_Mexican in forum What's Wrong With My Code?
    Replies: 10
    Last Post: November 27th, 2010, 10:15 PM
  4. JTextArea output problem
    By grimx in forum What's Wrong With My Code?
    Replies: 5
    Last Post: July 8th, 2010, 08:54 PM
  5. Digital map application with Java GUI
    By donjuan in forum AWT / Java Swing
    Replies: 3
    Last Post: May 15th, 2009, 04:32 AM