Hi there.
I've been writing a Java implementation of Conway's Game of Life to flex my GUI muscles and stay in shape. It consists of a class extending JPanel in which all of the drawing is done, and a main class where the panel is created and a JFrame is set up, and so on.
My JFrame has a JMenuBar with one JMenu, called "Simulation". Inside the Simulation menu there are two JMenuItems: "New Simulation..." and "Reset Simulation".
The problem I am having is that whenever I click the Simulation menu, it opens for a brief moment and I see the two menu items, but then it is painted over by the panel as soon as the next repaint happens.
I have investigated the setComponentZOrder method, and tried several permutations of the following code, to no avail.
frame.getContentPane().setComponentZOrder(menuBar, 0);
frame.getContentPane().setComponentZOrder(panel, 1);
How can I prevent my JPanel from painting over my expanded JMenu?