This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes i need to position my Caret 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 "i need to position my Caret" Watch "i need to position my Caret" New topic
Author

i need to position my Caret

Ola Kesh
Ranch Hand

Joined: Dec 24, 2002
Posts: 40
Hi,
i have a project am currently working on and i have a code such as this:
JTextArea a = new JTextArea();
. . .
. . .
. . .
a.getText();
a.setText(null); // to reset the JTextArea

at the output, i realised the Caret is not set, i have to click the JTextArea b4 it is set.
please what should i do?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
I don't knwo whether this will sort out your problem, but try resetting your text to empty string rather than null. See whether that makes any difference.

CR
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38075
    
  22
. . . and are there any methods in JTextArea or its superclasses like requestFocus() ? That might help, too. Have a look in the API, see what it says.

CR
 
wood burning stoves
 
subject: i need to position my Caret
 
Similar Threads
Disable Caret in a Document
Question on Scrolling in a JTextArea
Displaying line # with JTextArea
Why JeditorPane inside a JScrollPane start from buttom?
Event Listener for JTextArea?