aspose file tools*
The moose likes Beginning Java and the fly likes How to use Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "How to use "setCaretPosition"" Watch "How to use "setCaretPosition"" New topic
Author

How to use "setCaretPosition"

ho mingchang
Greenhorn

Joined: Jul 13, 2003
Posts: 3
import java.awt.*;
public class TextAreaExample {
public static void main(String argv[]) {
Frame f = new Frame("TextArea Example");
f.setLayout(new FlowLayout());
String str = "1234567890 234567890 34567890 4567890 567890";
TextArea ta3 = new TextArea(str, 2, 10, TextArea.SCROLLBARS_VERTICAL_ONLY);
f.add(ta3);
ta3.setCaretPosition(0);
f.pack();
f.setVisible(true);
}
}
When I compiled the file, it showed "Cannot set caret position until after the peer has been created". How should I modify the code?
Thank you very much for your help ^^
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Welcome to JavaRanch, ho mingchang!
I'm moving this to the Swing / JFC / AWT forum...
[ July 13, 2003: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to use "setCaretPosition"
 
Similar Threads
Khalid Programming Ex. 12.1
How to use "setCaretPosition"
displaying words in different fonts or colors in a textarea
Delete last character appended in TextArea
Printing to a text area