|
Java actionlistener help
I am making a Yahtzee game and i am having trouble getting the dice to change when i press my roll button. the dice are checkboxes so when they are selected, they can be "held".
For clarity's sake, ill just put the code for changing one of my dice from a one to a three. All my buttons and checkboxes show up just fine but when I click the buttons nothing happens.
Here are the relevant parts of my code:
private JButton roll;
private JCheckBox check;
in the constructor:
roll=new JButton("ROLL");
roll.setActionCommand("roll");
check=new JCheckBox();
Check1.setIcon(Dice1); //Dice1 is an ImageIcon
public void actionPerformed(ActionEvent e) {
if ("roll".equals(e.getActionCommand())
rollDice();}
public void rollDice(){
check.setIcon(Dice3);}
if all of the above is fine, then my problem is most likely with repainting. which leads to my other question...how would I get the screen to repaint itself after every time i press a button?
Thanks
|