Interactive console using Swing

O

Oleg Konovalov

Hi,

I am trying to implement an application administrative tool with interactive
console
(i.e. showing some info to the user and taking user input) using Swing and
JDK 1.4.

Up until now I have done info display part after selecting items from the
menu
(using JTextArea and append() ),
but now I realized that user input has to be provided and processed.

I don't see that I can associate an i/o stream with JTextArea. Is there a
way to do that ?

Or is there other Swing widget better suitable for that ?

Please advise.

Thank you in advance,
Oleg.
 
A

ak

I am not sure that I understood what you want.
If you want to type into JTextArea some commands which should be evaluated
then use Document.
I don't see that I can associate an i/o stream with JTextArea. Is there a
way to do that ?

InputStream in;
JTextArea area;

BufferedReader reader = new BufferedReader(new InputStreamReader(in));
while(true) {
String s = reader.readLine();
//do something with string here
area.append(s);
}
 
H

Hal Rosser

try using something like this:

JOptionPane.showInputDialog(null, "Enter your response",
"titlebarTextString" );
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,055
Latest member
SlimSparkKetoACVReview

Latest Threads

Top