Yes, you understood correctly what I've meant.
You say you want to emulate Windows command prompt or Linux terminals, but even this is quite vague specification -- there are certainly some differences between Linux and Windows consoles. A lot of things would have to be taken care of if you wanted to use
JTextArea and have it behave exactly as a Windows command prompt, for example:
- There is no
word wrap in console, lines wrap at the console width. If the console is resized, the text is not re-wrapped.
- You can only edit the last line ("prompt") in the console, the rest of the console is uneditable and cursor cannot go there (this is different from some Unix consoles, I think). Nevertheless, you can mark a text in the console (in strictly rectangular areas) and copy it to the clipboard.
- Various command completions (when Tab is pressed, for example) are available.
- Console keeps certain number of lines of text which you can scroll and inspect, when this number is reached, old lines are being scrolled away.
- You can use Alt-Enter (in Windows) to switch to text mode. Completely impossible to do with Swing.
There might be other differences I didn't think of.
I don't know your exact requirements or needs, so I don't know how important it is to handle the Enter key without any commands, but surely in the design I've suggested you could easily detect this and add the prompt to the output panel. If a program being run in your console requires user input, several possibilities exist: you might display an input box to let the user enter the input (SQL Developer does this I believe), or you might reactivate the input panel and let the user enter the input here. In both cases you would probably copy the user's input into the output panel. Output of any program would naturally go into the output panel (how to do this is a different matter not exactly specific to Swing).
My point is: you are going to use Swing. Use Swing strengths in your design, don't try to have the Swing form behave as a console. It is certainly possible (with some minor limitations, eg. Alt-Enter), but I think it is simply not worth the effort.
If you decide to implement the console, look around for existing implementations. Googling up
java swing console brings a few interesting links. There is
this component which seems not to be based on the
JTextArea control, and several threads on various forums discussing
JTextArea console implementations.