aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes JTextArea... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTextArea..." Watch "JTextArea..." New topic
Author

JTextArea...

Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Hi everyone,
Just a simple question...when using the JTextArea's method 'insert()', what kind of value does the position argument take? I mean, what position does it specify, for example if you have a textarea with x rows and y columns?
Thanks!


- Trish -
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
If you play around with it a bit, the answer soon reveals itself...
Starting with an empty JTextArea for each example:

inserts "hello" before the number 8,

inserts "hello" before the number 1, and

inserts "hello" before the number 0.
So, it looks like, the specified position is the position in the String contained in the JTextArea and counting starts at 0 at the beginning of the String - each character of the String being at a position in the String. And yes, the new line character '\n' counts as one character position.
Making sense?
Good Luck.
[ March 17, 2002: Message edited by: Dirk Schreckmann ]

[How To Ask Good Questions] [JavaRanch FAQ Wiki] [JavaRanch Radio]
Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Yes it does! Thanks a lot!
Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Hi again..
Does the row/column specifications in the JTextArea constructor allow you to insert values at identifed row/column positions? Or, is this just a way of specifying the area's size?
Thanks a lot!
Dirk Schreckmann
Sheriff

Joined: Dec 10, 2001
Posts: 7023
Originally posted by Tris Rabar:
Does the row/column specifications in the JTextArea constructor allow you to insert values at identifed row/column positions? Or, is this just a way of specifying the area's size?

After reading the JTextArea documentation, it becomes apparent what the available constructors do. Three constructors have parameters available for specifying rows and columns of the JTextArea - not for positioning text. This behavior soon reveals itself after making practice programs using them. If you were so inclined, you could use the new line character, '\n', and spaces in a string used with one of the available constructors to position your initial text. Note: The horizontal spacing is dependent on the font in use - one space character is (usually) not one column space.
Good Luck.
[ March 17, 2002: Message edited by: Dirk Schreckmann ]
Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Thanks Dirk...
you guys are so helpful!
Very much appreciated.
Tris Rabar
Ranch Hand

Joined: Feb 27, 2002
Posts: 72
Thanks Dirk...
you guys are so helpful!
Very much appreciated.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTextArea...
 
Similar Threads
Help with a get method that returns positions of a variable.
Passed OOAD 76% (IBM486)
TESCO Bangalore
Arrogant programmers and economic climate
XSLT iteration problem