java JTextField 和 JTextArea

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12714664/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 09:56:23  来源:igfitidea点击:

JTextField and JTextArea

java

提问by Asus HP

What is the different between JTextField and JTextArea? Is this possible to work with this two classes in a one class?

JTextField 和 JTextArea 有什么区别?这可以在一个班级中使用这两个班级吗?

回答by Redandwhite

In summary, a JTextField is a one-line text field, whereas a JTextArea can span over multiple lines.

总之,JTextField 是单行文本字段,而 JTextArea 可以跨越多行。

The differences are clearly explained in the documentation: JTextAreaandJTextField

文档中清楚地解释了差异:JTextArea and JTextField

Of course, you can use them in the same class. There would be zero conflicts between them.

当然,您可以在同一个类中使用它们。他们之间将有零冲突。

回答by Bruno Vieira

You can always refer to the javadocsfor such kind of question.

对于此类问题,您始终可以参考javadoc

You can work with both classes in one class. The main difference is the size, since JTextField are one line and JTextArea have columns and rows. (Which makes suitable for lots of information)

您可以在一个课程中使用两个课程。主要区别在于大小,因为 JTextField 是一行,而 JTextArea 有列和行。(这使得适合大量信息)