Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

setCaretPosition() with 1.4.2

  Asked By: Glenn    Date: Mar 18    Category: Java    Views: 2596

I'am experiencing some problems while using setCaretPosition() with
If I call..say..
mytextarea.setCaretPosition(0); The caret position remains unchanged!!

Is this a known problem or some error in the way I'am using it?



4 Answers Found

Answer #1    Answered By: Josie Roberts     Answered On: Mar 18

The caret position  wont change since you don't have a
value on settext and setcaretposition(0). The best way
to do this is do settext("this is the text") and
setcaretposition( 2) there you will see the
caretposition you had just set.

Answer #2    Answered By: Marc Anderson     Answered On: Mar 18

Here's the actual scenario:
User types in sometext in the TextArea and presses <ENTER>. Now, this text
has to be moved elsewhere and the TextArea should
be now blank with the caret at 0.

What do you propose?

Answer #3    Answered By: Kiet Jainukul     Answered On: Mar 18

do you have the code it will be easier for me to check it.

Answer #4    Answered By: Mae Roberts     Answered On: Mar 18

sendMessage is a java.awt.TextArea object that accepts user messages to be
sent across the network to another user whose
IP Address is picked from toField (which is java.awt.Choice).
sendMessage() sends a message by constructing the DatagramPacket.

This is the implementation of the keyPressed() method from the KeyListener
that sendMessages is registered with.

public void keyPressed(KeyEvent ke){

allMessages.append("localhost -

catch(Exception e){}



Didn't find what you were looking for? Find more on setCaretPosition() with 1.4.2 Or get search suggestion and latest updates.

Related Topics:



Related Post