Results 1 to 4 of 4
- 12-26-2012, 10:38 AM #1
Member
- Join Date
- Dec 2012
- Posts
- 32
- Rep Power
- 0
JTextArea differenet methode of inserting text
Hello Everyone and thanks for the help in advance :)
So I want to know if it's possible in a textarea to know the input method like from the keyboard or from the code, cause I want to make part of a text area uneditable while it's editable what I mean is before the postion of the caret the text can not be modified.
- 12-26-2012, 01:45 PM #2
Re: JTextArea differenet methode of inserting text
Looks like you what you need is camickr's Protected Text Component « Java Tips Weblog
dbWhy do they call it rush hour when nothing moves? - Robin Williams
- 12-27-2012, 02:12 PM #3
Member
- Join Date
- Dec 2012
- Posts
- 32
- Rep Power
- 0
Re: JTextArea differenet methode of inserting text
thanks for the response it's done!! :)
For anyone how might need it, this is the code :
Java Code:private class Filter extends DocumentFilter { int caretpos = Traffic.getCaretPosition(); @Override public void insertString(final FilterBypass fb, final int offset, final String string, final AttributeSet attr) throws BadLocationException { if (offset > 0 ){ super.insertString(fb, offset, string, attr); } } @Override public void remove(final DocumentFilter.FilterBypass fb, final int offset, final int length) throws BadLocationException { if ( (Traffic.getLineStartOffset(Traffic.getLineCount()-1) + promptposition()) - 1 < offset && (Traffic.getLineOfOffset(offset) == (Traffic.getLineCount() - 1)) ){ super.remove(fb, offset , length); }} @Override public void replace(final DocumentFilter.FilterBypass fb, final int offset, final int length, final String text, final AttributeSet attrs) throws BadLocationException { if (offset >= promptposition() ) { super.replace(fb,offset, length, text, attrs); } } }
- 12-27-2012, 05:07 PM #4
Similar Threads
-
Tell a jTextArea to keep the text it already has and put new text on a new line
By Burnett98 in forum New To JavaReplies: 2Last Post: 06-02-2012, 10:51 PM -
Need help with Reading string in text file and inserting them into a singly linked
By Googly in forum New To JavaReplies: 6Last Post: 05-12-2012, 04:29 AM -
Inserting line into text file
By Onra in forum Advanced JavaReplies: 5Last Post: 09-14-2010, 11:21 AM -
Scanning text file and inserting contents into array
By jmwalloh in forum New To JavaReplies: 8Last Post: 03-24-2010, 12:33 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks