Thread View: borland.public.jbuilder.java.swing
5 messages
5 total messages
Started by Benedict
Fri, 25 Nov 2005 14:53
JButton events tricker twice
Author: Benedict
Date: Fri, 25 Nov 2005 14:53
Date: Fri, 25 Nov 2005 14:53
2 lines
1177 bytes
1177 bytes
I have a JButton on my form that calls an actionPerformed event when clicked. I perform some routines in it and everything works fine except for some reason the event is always trickered twice when the button is clicked. Any idea what could cause this and how to stop it from happening.
Re: JButton events tricker twice
Author: Kevin Dean [TeamB]
Date: Fri, 25 Nov 2005 15:11
Date: Fri, 25 Nov 2005 15:11
28 lines
2271 bytes
2271 bytes
Benedict wrote: > >I have a JButton on my form that calls an actionPerformed event when >clicked. I perform some routines in it and everything works fine except >for some reason the event is always trickered twice when the button is >clicked. Any idea what could cause this and how to stop it from happening. Put a breakpoint in the event handler. When the breakpoint is triggered, press the green "Go" arrow at the bottom left to let the program continue running. When the breakpoint is triggered for the second time, look at the "Stack" tab in the debugger to investigate the stack trace. The odds are that you are indirectly calling the event handler recursively, perhaps by modifying the control in some way that is triggering the event a second time. -- Kevin Dean [TeamB] Dolphin Data Development Ltd. http://www.datadevelopment.com/ NEW WHITEPAPERS Team Development with JBuilder and Borland Enterprise Server Securing Borland Enterprise Server http://www.datadevelopment.com/papers/index.html Please see Borland's newsgroup guidelines at http://info.borland.com/newsgroups/guide.html
Re: JButton events tricker twice
Author: Benedict
Date: Fri, 25 Nov 2005 15:50
Date: Fri, 25 Nov 2005 15:50
109 lines
4370 bytes
4370 bytes
I did, but there is nothing in the stack that points to the event being called twice. To make sure it's not the code withing the event, I commented all code out except for one line. It still keeps on repeating even with just one line of code within it.
public void jBtnImportAllFMEA_actionPerformed(ActionEvent e) {
jTextArea1.setText("test");
/*try {
jTextArea1.setText("");
quickExit: {
File f = new File(UploadFolder);
if (f.isDirectory()) {
String filenames[] = f.list();
fn = "";
jTextArea1.setWrapStyleWord(true);
for (int i = 0; i < filenames.length; i++) {
if (isLocked(msoFMEAUploadFolder + filenames[i])) {
fn = fn + "\nFile " + filenames[i] +
" is locked by another application.";
break quickExit;
}
}
for (int i = 0; i < filenames.length; i++) {
}
for (int i = 0; i < filenames.length; i++) {
fn = fn + "Attempting to import " + filenames[i];
if (filenames[i].endsWith(".xls")) {
loadFMEA(msoFMEAUploadFolder + filenames[i]);
fn = fn + " - done";
moveFile(UploadFolder + filenames[i], FFolder);
}
fn = fn + "\n";
}
}
}
jTextArea1.setText(fn);
}
catch (Exception ex) {
ex.printStackTrace();
} */
}
}
class msoImportFMEA_jBtnImportAllFMEA_actionAdapter
implements ActionListener {
private msoImportFMEA adaptee;
msoImportFMEA_jBtnImportAllFMEA_actionAdapter(msoImportFMEA adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jBtnImportAllFMEA_actionPerformed(e);
}
}
class msoImportFMEA_jBtnImportFMEA_actionAdapter
implements ActionListener {
private msoImportFMEA adaptee;
msoImportFMEA_jBtnImportFMEA_actionAdapter(msoImportFMEA adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.jBtnImportFMEA_actionPerformed(e);
}
}
"Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote:
>Benedict wrote:
>
>>
>>I have a JButton on my form that calls an actionPerformed event when
>>clicked. I perform some routines in it and everything works fine except
>>for some reason the event is always trickered twice when the button is
>>clicked. Any idea what could cause this and how to stop it from happening.
>
>Put a breakpoint in the event handler. When the breakpoint is triggered,
>press the green "Go" arrow at the bottom left to let the program continue
>running. When the breakpoint is triggered for the second time, look at
>the "Stack" tab in the debugger to investigate the stack trace. The odds
>are that you are indirectly calling the event handler recursively, perhaps
>by modifying the control in some way that is triggering the event a second
>time.
>
>--
>Kevin Dean [TeamB]
>Dolphin Data Development Ltd.
>http://www.datadevelopment.com/
>
>NEW WHITEPAPERS
>Team Development with JBuilder and Borland Enterprise Server
>Securing Borland Enterprise Server
>http://www.datadevelopment.com/papers/index.html
>
>Please see Borland's newsgroup guidelines at
>http://info.borland.com/newsgroups/guide.html
Re: JButton events tricker twice
Author: Kevin Dean [TeamB]
Date: Fri, 25 Nov 2005 19:06
Date: Fri, 25 Nov 2005 19:06
23 lines
1859 bytes
1859 bytes
Benedict wrote: > >I did, but there is nothing in the stack that points to the event being >called twice. To make sure it's not the code withing the event, I >commented all code out except for one line. It still keeps on repeating >even with just one line of code within it. Then I'm afraid I can't add anything to that. I've never seen Swing buttons behave like that. -- Kevin Dean [TeamB] Dolphin Data Development Ltd. http://www.datadevelopment.com/ NEW WHITEPAPERS Team Development with JBuilder and Borland Enterprise Server Securing Borland Enterprise Server http://www.datadevelopment.com/papers/index.html Please see Borland's newsgroup guidelines at http://info.borland.com/newsgroups/guide.html
Re: JButton events tricker twice
Author: Benedict
Date: Tue, 06 Dec 2005 09:47
Date: Tue, 06 Dec 2005 09:47
27 lines
2062 bytes
2062 bytes
Just to close this off, the only way to solve this was to delete the button and put a new button on the form. Somebody else had this same problem and he emailed me, saying that this is the only way he could fix it. "Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com> wrote: >Benedict wrote: > >> >>I did, but there is nothing in the stack that points to the event being >>called twice. To make sure it's not the code withing the event, I >>commented all code out except for one line. It still keeps on repeating >>even with just one line of code within it. > >Then I'm afraid I can't add anything to that. I've never seen Swing >buttons behave like that. > >-- >Kevin Dean [TeamB] >Dolphin Data Development Ltd. >http://www.datadevelopment.com/ > >NEW WHITEPAPERS >Team Development with JBuilder and Borland Enterprise Server >Securing Borland Enterprise Server >http://www.datadevelopment.com/papers/index.html > >Please see Borland's newsgroup guidelines at >http://info.borland.com/newsgroups/guide.html
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads