wood burning stoves 2.0*
The moose likes Swing / AWT / SWT and the fly likes Text Area Problem... Pls Help Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Text Area Problem... Pls Help" Watch "Text Area Problem... Pls Help" New topic
Author

Text Area Problem... Pls Help

Srinivas Nagesh
Greenhorn

Joined: Oct 27, 2002
Posts: 19
Hi,
I would like to know how to position the cursor in a textarea to the row i want to?
Thanks
Greg Charles
Sheriff

Joined: Oct 01, 2001
Posts: 2771
    
  10

Assuming that you're using JTextArea, the cursor is actually a caret, and can be set with setCaret(). Unfortunately, that takes a position, not a line number as a parameter. However, you should be able to use getLineEndOffset(), and a little bit of logic to accomplish your goal.
Srinivas Nagesh
Greenhorn

Joined: Oct 27, 2002
Posts: 19
I am using AWT and not Swings.
Thanks.
[ January 15, 2003: Message edited by: Srinivas Nagesh ]
Robbie shi
Greenhorn

Joined: Jan 05, 2003
Posts: 28
setCaret(Caret c ) is Ok
---
Robbies
-----------------------------
1.java IDE tool : JawaBeginer
2.Java Jar tool : JavaJar
http://www.pivotonic.com
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Hi, I ripped the following from some old code of mine. Assume that this method exists in a class extending the TextArea class. Here it is:

kind regards
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Text Area Problem... Pls Help
 
Similar Threads
Cant use object from another class
Text box value is not being completely filled with request attribute
Posting to bump up my count...
WA #1.....word association
The x900 effect ?