-1

我一直在处理各种文本组件,现在我来这里寻求答案。

我需要的是一个用户可以使用键盘和/或复制/粘贴输入文本的区域。这些是组件的要求:

自动换行,限制行数的能力(自动换行),防止用户输入某些字符(或按回车换行)的能力,根据内容扩展和减小高度的能力(使内容适合组件并且没有(几个像素很好)剩余高度,能够直接或通过跟踪行号来检测其高度的变化。

4

1 回答 1

3

Have a look at the different Text Components provided by the Java API here: Using Text Components

in the above it has 3 different types of text components:

  • Text Controls
  • Plain Text Areas
  • Styled Text Areas

And it looks like the definition of the last Styled Text Areas fits your needs:

A styled text component can display editable text using more than one font. Some styled text components allow embedded images and even embedded components. Styled text components are powerful and multi-faceted components suitable for high-end needs, and offer more avenues for customization than the other text components. Because they are so powerful and flexible, styled text components typically require more initial programming to set up and use. One exception is that editor panes can be easily loaded with formatted text from a URL, which makes them useful for displaying uneditable help information.

These would include the likes of:

于 2012-08-27T17:30:31.640 回答