java - JTextField 正在锁定输入
问题描述
我正在使用 JTextField (xInput) 输入 x 坐标:
xInput.getDocument().addDocumentListener(new DocumentListener() {
public void changedUpdate(DocumentEvent e) {
updateX();
}
public void removeUpdate(DocumentEvent e) {
updateX();
}
public void insertUpdate(DocumentEvent e) {
updateX();
}
public void updateX() {
try {
x = Integer.parseInt(xInput.getText().trim());
} catch (NumberFormatException nfe) {
if (xInput.getText().equals("")) {
x = 0;
}
}
}
});
还有它的 y 对应物,尽管它们是相同的(除了它显然使用 y )并且有相同的问题。
运行程序后会发生什么 - 它使用机器人进行点击 - 当您尝试再次编辑文本字段时,这些字段被锁定,您可以单击或键入它们。我没有在任何地方使用 setEditable。这可能是什么原因造成的?
解决方案
推荐阅读
- youtube-api - 如何在不使用 You Tube Data API 的搜索功能的情况下获取频道正在进行的直播视频
- c# - 简单的 odata 客户端过滤器嵌套集合
- python - 单元测试不会运行测试
- azure - 如何在 Azure 函数中的 Configure(IWebJobsBuilder builder) 中获取 FunctionAppDirectory
- python - 递归函数只返回嵌套字典一个分支的结果
- google-places-api - 在哪里可以找到 address_components 类型的所有可能性?
- python - Python:插值 x、y、z 数据
- amazon-web-services - 加载 s3 时出现 java.lang.NoSuchMethodError
- kubernetes - 按环境删除所有 k8s 对象
- javascript - 使用数组减少来查找最大属性问题