• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

ActionListener compatibility issue

 
Ranch Hand
Posts: 52
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
An applet which I have written works with multiple browsers on Windows and Mac OS 9 and X; it's designed to be Java 1.1 compatible. However, when I tried it this past weekend with Mozilla on a Linux box, its buttons were non-functional. It's using the Blackdown JVM, Java 1.3.1. The buttons highlight appropriately when clicked, but the expected actions don't happen. (Actually, the actions did happen twice in a row after about forty tries, then wouldn't happen again.)
The applet class extends Applet and implements ActionListener.
editCmd is defined for the class as
static final String editCmd = "edit";

The applet's init() function calls
editButton = new Button("Edit");
editButton.setActionCommand(editCmd);
editButton.addActionListener(this);

The applet's destroy() function calls
editButton.removeActionListener(this);
removeActionListener isn't explicitly called anywhere else in the applet.
The actionPerformed function looks like this, with irrelevant code omitted:
public void actionPerformed(ActionEvent evt) {
String cmd = evt.getActionCommand();
try {
if (cmd.equals(editCmd))
/* do stuff */
}
/* Exception handling */
}
Does anyone have an idea why this fails just in some implementations?
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic