I've had to look at some code I work two years ago, as I haven't used Java since then (and Java is NOT JavaScript)
Where you have your public void actionPerformed(ActionEvent e)
(which is inside the class that implements the actionListener),
you have inside it a series of IFs
eg
if (e.getSource() == bBars)
{some thing to do}
if(e.getSource() == bLines)
{some other things to do}
if(e.getSource() == bPies)
{even more things to do}
if(e.getSource() == bExit)
{guess what this did next}
Where each bSomething was an instance of a button, in this case ones for drawing graphs. BUT I'm very out of practice with Java, so even though I was very good at it back then, I'm a bit limited in what I can remember now. Strangely, I was top of the class but never actually liked Java.
|