keep jButton grey until jTextFields != null

后端 未结 5 2044
暖寄归人
暖寄归人 2021-01-14 23:08

I have 4 jTextFields that I save the input to a file once a submit button is pressed. I want to be able to keep the submit button disabled until each field is at least not n

5条回答
  •  死守一世寂寞
    2021-01-15 00:10

    use the keyPressed listener for each textfield to run your check wherever the text of a textfield is changed.

    the method to disable the buttons is setEnabled(false);

    Note that you will have to make the buttons dissabled when the program starts if your textfiends are empty at that time (listeners won't run)

提交回复
热议问题