What should I do if I want to perform an ActionListener
on a button again and again, so that it will not give me the same ans again...
For example:
down = new JButton("DOWN-1");
down.setSize(down.getPreferredSize());
down.setLocation(100,200);
down.addActionListener(this);
left=new JButton("LEFT-1");
left.setSize(left.getPreferredSize());
left.setLocation(100,250);
left.addActionListener(this);
right=new JButton("RIGHT-1");
right.setSize(right.getPreferredSize());
right.setLocation(100,300);
right.addActionListener(this);
up1=new JButton("UP-2");
up1.setSize(up1.getPreferredSize());
up1.setLocation(550,150);
up.addActionListener(this);
@Override
public void actionPerformed(ActionEvent a)
{
int counter=370;
if (a.getSource()==up) {
System.out.println(counter);
x=250+62+62;
y=60+62+62+62+62+62;
b1.setLocation(x,counter-62);
l19.setLocation(x,counter);
}
}
In this I want to use up button again and again but it is not working...