hello!
can't find what is wrong wiht my code for eventhandling.
this is my check button event handling.
i am using swing. it won't compile.
here is my code. can yo take a look at it , please..
JRadioButton radiob1=new JRadioButton("Computer", true);
addComponent(radiob1,1,3,3,1);
JRadioButton radiob2=new JRadioButton("Player2", false);
addComponent(radiob2,5,3,3,1);
//create relationship of group
ButtonGroup radiogroup= new ButtonGroup();
radiogroup.add(radiob1);
radiob1.addItemListener(this);
radiogroup.add(radiob2);
i did this on top my class implements ItemListener
public void itemStateChanged(ItemEvent e)
{
if (e.getSource() == radiob1) <==error here
System.out.println("playing against computer"
else
System.out.println("Playing against player2"
}
thanks very much
Q
can't find what is wrong wiht my code for eventhandling.
this is my check button event handling.
i am using swing. it won't compile.
here is my code. can yo take a look at it , please..
JRadioButton radiob1=new JRadioButton("Computer", true);
addComponent(radiob1,1,3,3,1);
JRadioButton radiob2=new JRadioButton("Player2", false);
addComponent(radiob2,5,3,3,1);
//create relationship of group
ButtonGroup radiogroup= new ButtonGroup();
radiogroup.add(radiob1);
radiob1.addItemListener(this);
radiogroup.add(radiob2);
i did this on top my class implements ItemListener
public void itemStateChanged(ItemEvent e)
{
if (e.getSource() == radiob1) <==error here
System.out.println("playing against computer"
else
System.out.println("Playing against player2"
}
thanks very much
Q