JtextArea problem

I have a GUI interface in swing.

i have a button on it .

on click of a button i do the following as action performed.

JTextArea1.setText("some text");

Problem:

--

Now , i shall run a remote scriptin a unix machine and will get the String output as a return value into my GUI java program .

I wish to display this output as well in thesame JTextArea but with a scrollbar.

so, basically i want to have a TextArea with scrollbar whose contents will grow up dynamically (as it would come from running a unix script via ssh).

you will get something like below as a GUI.

STATUS TEXTAREA

Hello

output received after running script1:

sdcfsdfjsdfjsdfvdfvnfdv, v

xcvxcvxcvxcvxcvxcvxcvxvvxvx

output received after running script 2:

cdsjsb.vxdfvxcvbx.cvb.xcv.x

output received after running script 3:

cvzxbvm,xczvz,vxczbvzxm,vxz

xcvnxcm,vniklfjgiersjgergjerg

//blah blah

--

My investigation :

--

I have noticed if i put some more JTextArea.setText("some another text") ......it will replace the old text in the text areawhich i dont want ...........i want things to be appended with scrollbar .

Question :

-

can you give some idea ? how do i approach ?

[1317 byte] By [bronze-starDukes] at [2007-11-26 12:07:08]
# 1
1) In future Swing related questions should be posted into the Swing forum2) If you want to append text to a JTextArea use the append method instead of the setText method.3) Put your JTextArea in a JScrollPane
silverstar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 2
> i want things to be appended with scrollbar .I wonder if JTextArea has a method that can do this. Perhaps I will look in the API.
goldstar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 3

After over 300 postings on the forum you should be aware that swing related questions should be posted in the Swing forum.

> I have noticed if i put some more JTextArea.setText("some another

> text") ......it will replace the old text in the text area which i dont

Then don't use setText(...);

> .i want things to be appended with scrollbar .

Read the JTextArea API for another method you can be use to append() text to the text area.

platinumsta at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 4
Am I wrong about the ScrollPane?
silverstar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 5
sorry for this silly question.I overlooked the append() in the API.i found it .void append(String str) Appends the given text to the end of the document.Thank youdid i miss it in NETBEANS IDE !!!thanks for the response.
bronzestar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 6
> Am I wrong about the ScrollPane? No, the JTextArea must also be added to the JScrollPane.
platinumsta at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 7

> > Am I wrong about the ScrollPane?

>

> No, the JTextArea must also be added to the

> JScrollPane.

Ah thanks. Sorry I looked at the tutorial again after I asked but the way you worded your response before made me think there was some magic in JTextArea I was missing.

silverstar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 8

hi,

it seems to me append() nethod wont make the things dynamically.

it will wait for everything to be finished and then it will output as final.

i wanted the things to come one by one asynchronously.

because, script 1 may take x minute ( this is not fixed but suppose) to execute and return .

script 2 may take y ( this is not fixed but suppose)minute to execute and return .

i dont want to wait for x+y minute and thenoutput the whole .

i want to display the text message as soon as its finished .

so, it will actually come one by one .

is not it possible ?

somewhat like as similar as ajax does in web application.

what would be the best way to do it ?

bronzestar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...
# 9
Sounds like you're making an absolute pig's breakfast of your GUI by doing everything in the Event thread.My suggestion:Start a new thread in the Swing forum and post formatted, compilable code that demonstrates what you are doing.
silverstar at 2007-7-7 13:40:38 > top of Java-index,Archived Forums,Socket Programming...