java - 将只读字符串插入 jTextArea

标签 java string swing validation readonly

我正在使用一个接收关系代数表达式并将其转换为 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 。它允许您防止多个文本区域被更改。

该实现使用自定义DocumentFilterNavigationFilter来实现自定义功能。

关于java - 将只读字符串插入 jTextArea,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43151398/

相关文章:

java - 在运行时更改面板的高度

Java:获取变量的类

python - Pandas 系列列表到一个系列

java - 无法从类方法设置标签文本

c - 错误: too few arguments to function 'strcmp'

php - 打印/分解带斜杠的 PHP 字符串

java - JMenuBar - 使用快捷键 Ctrl+h 隐藏 JMenu,setVisible(false) 后按键不起作用

java - NoClassDefFoundError 和 ClassNotFoundException 的原因和区别是什么?

java - jmeter 响应时间和我在日志文件中看到的之间的差异

java - 文件处理java