File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes How to set the cursor position to new line when a specific char is typed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set the cursor position to new line when a specific char is typed" Watch "How to set the cursor position to new line when a specific char is typed" New topic
Author

How to set the cursor position to new line when a specific char is typed

Karnati Sudhakar
Ranch Hand

Joined: Aug 26, 2008
Posts: 270

Hi All,

I have a specific requirement that when user types a specific character..cursor should go to the next line..

I have code like this



what happening now is when i type ~ a new line is added but cursor is not moving to the next line..

Please suggest me..


Regards
Sudhakar
Chinna Eranna
Ranch Hand

Joined: Dec 08, 2009
Posts: 174

try inserting.. "\n\r"


- Chinna
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2153
    
    7
Maybe you also need:

textArea.setCaretPosition( current position + 1);
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: How to set the cursor position to new line when a specific char is typed
 
Similar Threads
Looping through a text file with an iterator
Can't generate java classes from WSDL file
Deprecated function authscheme(). Need Help to resolve this issue
how to color a particular word in a jtextpane?
how to paint a particular word in a string ?