GeeCON Prague 2014*
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: 2853
    
  11

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
 
GeeCON Prague 2014
 
subject: Text Area Problem... Pls Help