JTextField setEnabled vs setEditable

烈酒焚心 提交于 2019-12-04 02:59:41

In my case setEditable(false) is graying the field and setEnabled(false) not graying the field.

TextField are editable by default. The code setEditable(false) makes the TextField uneditable. It is still selectable and the user can copy data from it, but the user cannot change the TextField's contents directly.


The code setEnabled(false), disables this TextField. It is not selectable and the user can not copy data from it and the user cannot change the TextField's contents directly.


Useful Links

  1. How to Use Text Fields
  2. Component#setEnabled()

While setEnabled(false) grays out the field comletely, setEditable(false) just prevents it from beeing edited, but it will still look the same.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!