如何重置/清除JRadiobutton
?清除TextField
就像surenameField.setText("");
一样简单RadioButton
是否有类似的方式?
答案 0 :(得分:2)
你的意思是
radioButton.setSelected(false);
答案 1 :(得分:0)
如果您要清除名为JRadioButton
的{{1}}的文字,请致电radio
。如果您要取消选择该按钮,请致电radio.setText("")
。请注意,这实际上不会触发事件,因此如果您注册了一个侦听器以响应取消选择事件,则不会通知该侦听器。
有关详细信息,请阅读radio.setSelected(false)
此处
答案 2 :(得分:0)
你可以用“重置”来指明你的意思吗?
以下是可能的:
[container].remove([radioButton]
,例如myPanel.remove(myRadioButton)
来执行此操作。myRadioButton.setText("")