我正在使用一个接收关系代数表达式并将其转换为 SQL 查询的翻译器,我已经编写了翻译器代码,但在验证用户的输入时遇到了一些问题。
翻译器使用在文本区域中插入默认表达式的按钮,并为用户提供一个空白空间来输入一些参数,下面是一个示例:
Seleccionar(-the user enters parameters here-)( -the user enters parameters here- )
有没有办法让“Seleccionar”这个词和括号只读?那么用户无法编辑默认表达式?
最佳答案
Is there a way to make the word "Seleccionar" and the brackets read-only? So the user can't edit the default expressions?
查看 Protected Text Component 。它允许您防止多个文本区域被更改。
该实现使用自定义DocumentFilter
和NavigationFilter
来实现自定义功能。
关于java - 将只读字符串插入 jTextArea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43151398/