我在我的swing應用程序上有5個JRadio按鈕。當我點擊我的Jradio按鈕。我創建了一個指示對話來顯示它被點擊。但是當我取消選擇它時,它也會顯示它被選中。問題是什麼? 我的Jradio按鈕編碼之一。如何顯示JRadio按鈕被選中和取消選擇?
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
JOptionPane.showMessageDialog(null,"one is selected");
}
所以,我終於得到了回答
與@Neil Locketz幫助
private void jRadioButton1ActionPerformed(java.awt.event.ActionEvent evt)
{
if(jRadioButton1.isSelected())
{
JOptionPane.showMessageDialog(null,"one is selected");
}
}
感謝
有了這段代碼,很難說出是怎麼回事。 –
如果Neil幫助你,請upvote並接受他的回答。 – 2013-01-31 13:41:23