aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes How to set the text in JTextarea from bottom. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to set the text in JTextarea from bottom." Watch "How to set the text in JTextarea from bottom." New topic
Author

How to set the text in JTextarea from bottom.

Sandeepesh shah
Greenhorn

Joined: Feb 11, 2010
Posts: 10
Hi All,
I just want to set the text into textarea start from bottom to top.
But i am not able to do it.what should i supposed to do or is there any other component of having the propert to set the text from bottom to top.

waiting for reply.......
Sandeepesh shah
Greenhorn

Joined: Feb 11, 2010
Posts: 10
sandeepshah shah wrote:Hi All,
I just want to set the text into textarea start from bottom to top.
But i am not able to do it.what should i supposed to do or is there any other component of having the propert to set the text from bottom to top.

waiting for reply.......
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 39396
    
  28
sandeepshah shah wrote:waiting for reply.......
And you expected a reply within an hour and twenty minutes?
Raphael Okochu
Greenhorn

Joined: Jul 17, 2009
Posts: 22
You cannot do that with the default jTextArea. You will have to extend the Class JTextArea. If you mean extracting the contents of a JTextArea, you can use a stack. Please you have to give more details.


SCJP 5
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19719
    
  20

Moving to our GUI forum.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18655
    
    8

Yes, Raphael is right. You should explain what it means to "set text into a JTextArea from bottom to top".
Sandeepesh shah
Greenhorn

Joined: Feb 11, 2010
Posts: 10
Ok I explain in more detailed what i want to do.

I have a JTextarea of setbounds width=200 and height =50.in which suppose i can write 5 line ok.

but my text generate dynamically it is not sure whether it will fit into 2 line 3 line or more.......

if suppose my dynamic text feet till 3 line and i have the height of Jtextarea is 50 which can hold 5number of line so the last
2 line will remain blank ok/

But i want to set my dynamic text from bottom to top.means all my three line should feet from line number 5,4,3

and my JTextarea will display the above two line blank and the last three line should hold my dynamic text......

for more clearity please check the attachment........



[Download JtextareaAttachment.bmp] Download

Sandeepesh shah
Greenhorn

Joined: Feb 11, 2010
Posts: 10

In simple way:

String s ="First Line \n"+"Second Line \n"+"Third Line"; // The value of String s would be dynamic.
JTextArea jt = new JTextArea();
jt.setText(s);

please find the attachment


[Download JtextareaAttachment.bmp] Download

Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

At run time, figure out how many lines of text you got. Based on that, prepend those many \n to your text and then set it to the text area. You will need to work out the linewrap problem though.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
Sandeepesh shah
Greenhorn

Joined: Feb 11, 2010
Posts: 10
Thank's I hope it should work.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10451
    
    8

sandeepshah shah wrote:

Please check your private messages for an important administrative matter.
Rob Camick
Ranch Hand

Joined: Jun 13, 2009
Posts: 2200
    
    7

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: How to set the text in JTextarea from bottom.