0

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?

4

3 回答 3

2

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.

于 2008-10-24T18:02:02.913 回答
0

我不确定我是否明白了您的问题,但您可以使用 getText() 方法获取用户输入的文本:

JTextArea ta = new JTextArea(); 字符串输入 = ta.getText();

于 2008-10-24T22:03:28.353 回答
0

看看这个太阳图:

http://java.sun.com/docs/books/tutorial/uiswing/components/textarea.html

特别是,向下滚动到“TextAreaDemo”示例。

于 2009-08-17T13:57:06.797 回答