B
Blah Blah
i've been getting a strange bug when running an applet in internet explorer
on windows. i'm not sure if it's windows or internet explorer related, but
it doesn't happen on my linux box with netscape. the problem is this:
i have an applet which opens a frame. the frame has a default button
(btnOK), which opens a JOptionPane. so far so good. if, however, the user
holds down the Enter key so that it auto-repeats, after cycling through
these a couple of times IE freezes and has to be shutdown from the task
manager. i had similar behavior on the linux box until i put a simple
semaphore in, but that doesn't seem to have helped with windows. here's the
code:
package view;
import java.awt.event.*;
import javax.swing.*;
public class TestLauncher extends JApplet
{
private static boolean okSemaphore = false;
private Tester tester;
public void init() {
super.init();
tester = new Tester();
}
public void start() {
tester.show();
}
public void stop() {}
public void destroy() {}
private final class Tester extends JFrame {
public Tester() {
super("Tester");
JPanel pnlContent = (JPanel)getContentPane();
JButton btnTest = new JButton("OK");
btnTest.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ev){
doOK();
}});
pnlContent.add(btnTest);
getRootPane().setDefaultButton(btnTest);
pack();
}
private final void doOK() {
if (okSemaphore == false) {
okSemaphore = true;
int result = JOptionPane.showOptionDialog(
this,
"Message",
"Tester",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
new Object[] {"OK","Override"},
"OK");
okSemaphore = false;
}
}
}
}
any ideas?
daniel
on windows. i'm not sure if it's windows or internet explorer related, but
it doesn't happen on my linux box with netscape. the problem is this:
i have an applet which opens a frame. the frame has a default button
(btnOK), which opens a JOptionPane. so far so good. if, however, the user
holds down the Enter key so that it auto-repeats, after cycling through
these a couple of times IE freezes and has to be shutdown from the task
manager. i had similar behavior on the linux box until i put a simple
semaphore in, but that doesn't seem to have helped with windows. here's the
code:
package view;
import java.awt.event.*;
import javax.swing.*;
public class TestLauncher extends JApplet
{
private static boolean okSemaphore = false;
private Tester tester;
public void init() {
super.init();
tester = new Tester();
}
public void start() {
tester.show();
}
public void stop() {}
public void destroy() {}
private final class Tester extends JFrame {
public Tester() {
super("Tester");
JPanel pnlContent = (JPanel)getContentPane();
JButton btnTest = new JButton("OK");
btnTest.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ev){
doOK();
}});
pnlContent.add(btnTest);
getRootPane().setDefaultButton(btnTest);
pack();
}
private final void doOK() {
if (okSemaphore == false) {
okSemaphore = true;
int result = JOptionPane.showOptionDialog(
this,
"Message",
"Tester",
JOptionPane.DEFAULT_OPTION,
JOptionPane.WARNING_MESSAGE,
null,
new Object[] {"OK","Override"},
"OK");
okSemaphore = false;
}
}
}
}
any ideas?
daniel