🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.language
Article #19403

ActionPerformed runs twice??!!??

#19403
From: Conrad Hoesle-Kienzlen
Date: Wed, 11 Feb 1998 00:00
55 lines
2982 bytes
When the user clicks on the "Help" button, I display a modal message
dialog with instructions. This works almost too well, since that message
dialog always appears twice. After I click on the OK button on that
dialog it vanishes and immediately appears again. The call of the
message dialog is done through the JBuilder-generated actionPerformed
handler of the button:

.................................................................................................................

  // Display help text
  void btHelp_actionPerformed(ActionEvent e) {
    TextBox msgHelp = new TextBox("Help for Cash Flow Analyzer");
    msgHelp.setColor(new Color(150, 255, 255));
    msgHelp.setFont(new Font("Dialog", 0, 14));
    String msg =
      "Enter any four of the five values and leave the one to be\n"+
      "calculated empty. Then click on \"Calculate\" and the fifth\n"+
      "value will be returned by APL. Click \"Clear\" to empty all
fields.\n"+
      "NOTE: We do not take ANY responsibility WHATSOEVER as to the\n"+
      "correctnes or usefulness of the results. This is a demo
application!";
    msgHelp.setMessage(msg);
    msgHelp.show();
    this.requestFocus();
  }
-----------------line numbers added for clarification ------------------

1 :  class AplCli_btHelp_actionAdapter implements
java.awt.event.ActionListener{
2 :   AplCli adaptee;
3 :
4 :   AplCli_btHelp_actionAdapter(AplCli adaptee) {
5 :     this.adaptee = adaptee;
6 :    }
7 :
8 :   public void actionPerformed(ActionEvent e) {
9 :     adaptee.btHelp_actionPerformed(e);
10:    }
11: }
.................................................................................................................

When I stepped through the code with the debugger, it showed me what
happens but not the reason: when the Help button is clicked, line 9 in
the lower part of the listing gets highlighted, then all the code in the
upper part is run, at the msgHelp.show() point the message box appears,
then, after I clicked OK there, the this.requestFocus() is called.
Then the debugger jumps to the lower part again, line 10 gets
highlighted and at the next press on F7 the highlight jumps back to line
9 and the whole process starts over.
After I discovered this peculiar behaviour, I traced methods called by
other actionPerformed handlers (one very simple, it just sets the text
property of all text fields to "") and they all behave the same, they
are all called twice!
Technical Details
Message-ID: <34E1A97E.AF546CDE@csi.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f74b3,7cde37185d90791a,start
X-Google-Attributes: gidf74b3,public
From: Conrad Hoesle-Kienzlen <Conrad_Hoesle@csi.com>
Subject: ActionPerformed runs twice??!!??
Date: 1998/02/11
Message-ID: <34E1A97E.AF546CDE@csi.com>
X-Deja-AN: 324107196
Content-Transfer-Encoding: 7bit
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Organization: CHK IT-Consulting
Newsgroups: borland.public.jbuilder.java.language