I want to load up a window using the java swing, something like this
However I want to be able to use it for text input also not just to dump data into it..
any idea how to do it?
JTextAreas are editable by default, so input is trivial. Just put one into a test UI and see for yourself.
From a design perspective, using the same JTextArea for both input and output strikes me as unwise. The only example I can think of is a shell interface, and that imposes stronger limits on how input and output works than a JTextArea will provide out of the box.
我不确定我是否明白了您的问题,但您可以使用 getText() 方法获取用户输入的文本:
JTextArea ta = new JTextArea(); 字符串输入 = ta.getText();
看看这个太阳图:
http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html
特别是,向下滚动到“TextAreaDemo”示例。