S
Sam Brightman
Hi,
Can anyone explain the following? First, I click on a JMenu and its
JPopupMenu appears full of JMenuItems. Next, click a JMenuItem that
launches another JDialog (or similar, here it's a FileDialog). When the
dialog is closed, click the JMenu again. The JPopupMenu displays.
However, when attempting to use the resulting JPopupMenu, it seems that
the mouseEntered event causes it to vanish. This requires the user to
move the mouse back over (no click) the JMenu to make the JPopupMenu
visible again (the second time it *is* usable). I've spent hours trying
to fix this simple but frustrating problem with no success. I'm sure it
must be simple but I can't find an answer on Google yet...
--
sam brightman
(To reply by e-mail use spam instead of ham and lose the jam)
import java.awt.FileDialog;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
JMenuBar jmb = new JMenuBar();
JMenu jm = new JMenu("Test");
JMenuItem jmi = new JMenuItem("test");
jmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { load(); }
});
jm.add(jmi);
jmb.add(jm);
setJMenuBar(jmb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
pack();
show();
}
public static void main(String[] argv) {
Test t = new Test();
}
public void load() {
FileDialog f=new FileDialog(this,"Open",FileDialog.LOAD);
f.show();
}
}
Can anyone explain the following? First, I click on a JMenu and its
JPopupMenu appears full of JMenuItems. Next, click a JMenuItem that
launches another JDialog (or similar, here it's a FileDialog). When the
dialog is closed, click the JMenu again. The JPopupMenu displays.
However, when attempting to use the resulting JPopupMenu, it seems that
the mouseEntered event causes it to vanish. This requires the user to
move the mouse back over (no click) the JMenu to make the JPopupMenu
visible again (the second time it *is* usable). I've spent hours trying
to fix this simple but frustrating problem with no success. I'm sure it
must be simple but I can't find an answer on Google yet...
--
sam brightman
(To reply by e-mail use spam instead of ham and lose the jam)
import java.awt.FileDialog;
import java.awt.event.*;
import javax.swing.*;
public class Test extends JFrame {
public Test() {
JMenuBar jmb = new JMenuBar();
JMenu jm = new JMenu("Test");
JMenuItem jmi = new JMenuItem("test");
jmi.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { load(); }
});
jm.add(jmi);
jmb.add(jm);
setJMenuBar(jmb);
addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
pack();
show();
}
public static void main(String[] argv) {
Test t = new Test();
}
public void load() {
FileDialog f=new FileDialog(this,"Open",FileDialog.LOAD);
f.show();
}
}