N
nick yakman
I have 2 groups of buttons in an applet. One set of buttons to represents
money and the other set selects an item.
I have used:
money1p = new Button("1p");
money1p.addActionListener(this);
moneyKeyPanel.add(money1p);
money2p = new Button("2p");
money2p.addActionListener(this);
moneyKeyPanel.add(money2p);
ect for the money keys, with:
public void actionPerformed(ActionEvent ae)
{
String command = ae.getActionCommand();
int addedCredit = 0;
if(command.equals("1p"))
addedCredit = 1;
else if(command.equals("2p"))
addedCredit = 2;
else if(command.equals("5p"))
addedCredit = 5;
else if(command.equals("10p"))
addedCredit = 10;
ect..
totalCredit+= addedCredit;
}
This set of buttons works fine. But i cant set up a similar
"actionPerformed" Method for the second set of buttons.
Can they be added to the actionPerformed Method without interfering or how
can i set up a second actionPerformed method.
All help welcome
Many thanks
money and the other set selects an item.
I have used:
money1p = new Button("1p");
money1p.addActionListener(this);
moneyKeyPanel.add(money1p);
money2p = new Button("2p");
money2p.addActionListener(this);
moneyKeyPanel.add(money2p);
ect for the money keys, with:
public void actionPerformed(ActionEvent ae)
{
String command = ae.getActionCommand();
int addedCredit = 0;
if(command.equals("1p"))
addedCredit = 1;
else if(command.equals("2p"))
addedCredit = 2;
else if(command.equals("5p"))
addedCredit = 5;
else if(command.equals("10p"))
addedCredit = 10;
ect..
totalCredit+= addedCredit;
}
This set of buttons works fine. But i cant set up a similar
"actionPerformed" Method for the second set of buttons.
Can they be added to the actionPerformed Method without interfering or how
can i set up a second actionPerformed method.
All help welcome
Many thanks