如果选择了两个切换按钮但不匹配,请将按钮设置回空白图像…Java Gui
使用切换按钮创建基本记忆游戏如果选择了两个切换按钮但不匹配,请将按钮设置回空白图像…Java Gui,java,swing,user-interface,Java,Swing,User Interface,使用切换按钮创建基本记忆游戏 private void tbtnCard3ActionPerformed(java.awt.event.ActionEvent evt) { tbtnCard3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Card3Logo.png"))); if(tbtnCard5.is
private void tbtnCard3ActionPerformed(java.awt.event.ActionEvent evt) {
tbtnCard3.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Card3Logo.png")));
if(tbtnCard5.isSelected()){
score++;
lblScore.setText(""+score);
}
}
private void tbtnCard4ActionPerformed(java.awt.event.ActionEvent evt) {
tbtnCard4.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Card7EWaste.png")));
if(tbtnCard7.isSelected()){
score++;
lblScore.setText(""+score);
}
}
private void tbtnCard5ActionPerformed(java.awt.event.ActionEvent evt) {
tbtnCard5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Card3Logo.png")));
if(tbtnCard3.isSelected()){
score++;
lblScore.setText(""+score);
}
}
有更多的切换按钮,但我如何使它,如果两张卡被选中,他们不匹配设置为空或像一个空白图像。在此期间,我需要禁用所有其他按钮,以便在显示两个按钮时用户不能继续按下其他按钮。我不太确定如何才能让两个选定按钮上的图标先显示,然后返回空白图像,直到再次按下为止