Name: md23716 Date: 02/27/2001
Problem is observed with Plugin version 1.3.0-C. Use the programs below to reproduce.
Start a browser, load the applet, wait for the applet to start.
Now using the browser back button go back to
the previous applet, whilst it is loading, using the browser forward button
go forward to the other applet. Keep on flicking back and forward
(sometimes takes about 20 tries) and you will eventually end up with
multiple copies of the applets running at once. You sometimes have to be
quite specific about the amount of time between hitting forward and hitting
back, usually works if you press as soon as one button becomes un-greyed.
The customer has larger applets across a slower link whilst waiting for the
applet to download into the browser users have believed the browser to not
be responding and so have pressed the back button to get to the previous
web page. When that has not worked either they have used a combination of
back and forward until they get multiple applets, as with the testcase.
SwingAppletFrame.java:
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import javax.swing.*;
/**
* A very simple applet.
*
* ATTENTION:
* This example has been modified for test purposes:
* The example can be executed as an application or an applet.
* It starts its own frame, also when executed as an applet.
*
*/
public class SwingAppletFrame extends JApplet {
private static boolean cvIsApplet = true;
public void init() {
new SwingAppletImpl().show();
}
public static void main(String[] args) {
cvIsApplet = false;
new SwingAppletFrame().init();
}
class SwingAppletImpl extends JFrame {
JButton button;
public SwingAppletImpl() {
// Force SwingApplet to come up in the System L&F
String laf = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(laf);
// If you want the Cross Platform L&F instead, comment out the above line and
// uncomment the following:
// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException exc) {
System.err.println("Warning: UnsupportedLookAndFeel: " + laf);
} catch (Exception exc) {
System.err.println("Error loading " + laf + ": " + exc);
}
getContentPane().setLayout(new FlowLayout());
button = new JButton("Hello, I'm a Swing Button!");
getContentPane().add(button);
setTitle("SwingApplet-Test");
setSize(new Dimension(200,200));
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (cvIsApplet)
dispose();
else
System.exit(0);
}
});
}
}
}
The second applet is the same, but has a wait on startup:
import java.awt.*;
import java.awt.event.*;
import java.net.*;
import java.applet.*;
import javax.swing.*;
/**
* A very simple applet.
*
* ATTENTION:
* This example has been modified for test purposes:
* The example can be executed as an application or an applet.
* It starts its own frame, also when executed as an applet.
*
*/
public class SwingAppletFrame extends JApplet {
private static boolean cvIsApplet = true;
public void init() {
new SwingAppletImpl().show();
}
public static void main(String[] args) {
cvIsApplet = false;
new SwingAppletFrame().init();
}
class SwingAppletImpl extends JFrame {
JButton button;
public SwingAppletImpl() {
// Force SwingApplet to come up in the System L&F
String laf = UIManager.getSystemLookAndFeelClassName();
try {
UIManager.setLookAndFeel(laf);
// If you want the Cross Platform L&F instead, comment out the above line and
// uncomment the following:
// UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
} catch (UnsupportedLookAndFeelException exc) {
System.err.println("Warning: UnsupportedLookAndFeel: " + laf);
} catch (Exception exc) {
System.err.println("Error loading " + laf + ": " + exc);
}
getContentPane().setLayout(new FlowLayout());
button = new JButton("Hello, I'm a Swing Button!");
getContentPane().add(button);
setTitle("SwingApplet-Test");
setSize(new Dimension(200,200));
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
e.printStackTrace();
}
addWindowListener( new WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (cvIsApplet)
dispose();
else
System.exit(0);
}
});
}
}
}
======================================================================