Teen Programmers Unite  
 

 

Return to forum top

actionListener in java

Posted by ktf [send private reply] at September 29, 2002, 05:17:22 AM

I am having trouble trying to get a simple program to update the JPanel with a new figure using actionListeners. The program compiles but does absolutely nothing when the buttons are clicked. The logic I have used is;

public void actionPerformed(ActionEvent evt){
      Object source = evt.getsource();
if(source == gaussianButton){
update(gaussianButton);
}
else {
update(parabolicButton);
}


I have set up an update method, is the problem likely to be there?
Posted by taubz [send private reply] at September 29, 2002, 10:23:24 AM

Did you make the class that contains actionPerformed an action listener of the JPanel, or is the actionPerformed method within your JPanel class?

Test whether the actionPerformed function is being called by adding a System.err.println call and looking at the console.

- taubz

Posted by Psion [send private reply] at September 29, 2002, 10:23:53 AM

Did you register the actionListeners with the appropriate objects? If so, the problem is probably with your update method.

You must be logged in to post messages and see which you have already read.

Log on
Username:
Password:
Save for later automatic logon

Register as a new user
 
Copyright TPU 2002. See the Credits and About TPU for more information.