JMenuItem doesn't disappear when clicking on the titlebar. Is this a bug?
Hi Folks!
I have a JFrame with a JMenuBar.
When I click on a JMenu, the corresponding JMenuItems are displayed but they DO NOT disappear when I click on the titlebar!
If I click anywhere else on the frame they will disappear but NOT clicking on the titlebar.
Did any of you already had this ploblem?
Is this a known bug?
Thank you
Claudia
[401 byte] By [
umanic] at [2007-9-26 2:28:40]

Hard to believe!
Try this simple code that creates a JFrame with a JMenu...open the JMenu and then click on the titlebar...the menu won't disappear!
Claudia
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class MyFrame extends JFrame implements WindowListener {
static MyFrame frame;
MyFrame() {
super();
addWindowListener(this);
setTitle("Title bar");
setSize(600, 200);
JPanel panel = new JPanel();
JPanel buttonPanel = new JPanel();
JMenuBar menuBar = new JMenuBar();
JMenu fileMenu = new JMenu("File");
JMenuItem newMenuItem = new JMenuItem("New");
JMenuItem openMenuItem = new JMenuItem("Open");
JMenuItem closeMenuItem = new JMenuItem("Close");
fileMenu.add(newMenuItem);
fileMenu.add(openMenuItem);
fileMenu.add(closeMenuItem);
menuBar.add(fileMenu);
JLabel label = new JLabel("Open the menu and then click on the titlebar...does it disappear?");
label.setFont(new Font("Times New Roman", Font.BOLD, 15));
panel.add(BorderLayout.CENTER, label);
getContentPane().add(BorderLayout.CENTER, panel);
getContentPane().add(BorderLayout.NORTH, menuBar);
}
public void windowClosing(WindowEvent e){
frame.dispose();
System.exit(0);
}
public void windowClosed(WindowEvent e){
}
public void windowActivated(WindowEvent e){
}
public void windowDeactivated(WindowEvent e){
}
public void windowOpened(WindowEvent e){
}
public void windowIconified(WindowEvent e){
}
public void windowDeiconified(WindowEvent e){
}
public static void main(String args[]) {
frame = new MyFrame();
frame.show();
frame.setLocation(200, 200);
frame.toFront();
}
}