uncheck checkboxes in java

后端 未结 5 939
借酒劲吻你
借酒劲吻你 2021-01-02 17:04

In my program, I want to uncheck all the checkboxes whenever this method is called. Can someone explain why it isn\'t working? Whenever I call this method the checkboxes are

5条回答
  •  渐次进展
    2021-01-02 17:25

    In general in Swing any change made in the backend is not propagated to the visual elements. One good known exception is JTextField.setText() (any call to setText will update the visual text element immediatly).

    It is even documented in the API doc: http://docs.oracle.com/javase/6/docs/api/javax/swing/AbstractButton.html#setSelected(boolean).

    You may stay with your code but then you have to (in)validate the container.

提交回复
热议问题