erotavlas
November 29th, 2013, 04:08 PM
Hi,
I'm new of Java and I have a trouble with Jbutton. I learned that I can add an addActionListener to Jbutton as follow:
Jbutton Button1 = new Jbutton("1");
Button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
}
The Jbutton is contained inside a Jdialog together with other Jlabels and Jlist, the code is standard. In the code, I call a function that contains the Jbutton listener. The first time that the function is called, when the Jbutton is activated is executed the code inside the body and all work well. Then when I press the button for the second time, the code inside the body is executed two times. Then three time and so on. It seems that Jbutton has a sort of counter that is increased each time that the button is pressed. I cannot figure out where could be the problem and I have not found the answer on the web.
Thank you
I'm new of Java and I have a trouble with Jbutton. I learned that I can add an addActionListener to Jbutton as follow:
Jbutton Button1 = new Jbutton("1");
Button1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
}
}
The Jbutton is contained inside a Jdialog together with other Jlabels and Jlist, the code is standard. In the code, I call a function that contains the Jbutton listener. The first time that the function is called, when the Jbutton is activated is executed the code inside the body and all work well. Then when I press the button for the second time, the code inside the body is executed two times. Then three time and so on. It seems that Jbutton has a sort of counter that is increased each time that the button is pressed. I cannot figure out where could be the problem and I have not found the answer on the web.
Thank you