Results 1 to 4 of 4
- 05-29-2011, 06:01 AM #1
Member
- Join Date
- Dec 2009
- Posts
- 14
- Rep Power
- 0
Disable enter/return key in JTextArea
Hello, im working on a project where i ask people to type an announcement into a textarea and it saves it to a datafile, but if you click the enter key it moves down to the next line and when it saves it to my datafile it corrupts it, so i wanted to make it so they cant click enter and start a new line. i was wondering if there is a simple way of just disabling it or if i need an keylistener and if so then how would i go about doing that?
Thanks :(rofl):
- 05-29-2011, 06:16 AM #2
Member
- Join Date
- May 2011
- Location
- Maryland
- Posts
- 38
- Rep Power
- 0
Yup, just use the setEnabled method like so..
Java Code:JTextArea sample = new JTextArea(); sample.setEditable(false);
- 05-29-2011, 05:08 PM #3
Set a DocumentFilter that doesn't pass "\n" or use the approach outlined in camickr's Single Line Text Area.
db
- 05-29-2011, 05:59 PM #4
Member
- Join Date
- Dec 2009
- Posts
- 14
- Rep Power
- 0
Similar Threads
-
automatic ENTER?
By glina126 in forum New To JavaReplies: 3Last Post: 02-25-2011, 07:08 AM -
How Enter key act like TAB?
By mine0926 in forum New To JavaReplies: 2Last Post: 06-03-2010, 06:44 AM -
JTextArea on PopUp -JTextArea isn't editable
By Richy76 in forum AWT / SwingReplies: 3Last Post: 02-01-2010, 07:51 PM -
Enter
By Arnold in forum New To JavaReplies: 8Last Post: 10-18-2009, 09:17 AM -
enter key in swt
By ashin in forum SWT / JFaceReplies: 0Last Post: 07-17-2009, 09:42 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks