I have recently started making a minesweeper-like game in java with swing (using eclipse WindowBuilder), and in the app there is an ordinary JFrame with a JMenu with options in it. It works as it should until window is resized. Then, when I click on the menu to show it, it is shown only until I release the mouse button, and then it dissapears as if I clicked soewhere else. But when I access the menu by keyboard shortcut, it works properly. Does anyone know where might the problem be? Code of menu:
JMenu mnHelp = new JMenu( "Help" );
mnHelp.setMnemonic( 'h' );
menuBar.add( mnHelp );
JMenuItem mntmControls = new JMenuItem( "Controls" );
mntmControls.setMnemonic( 'c' );
mntmControls.setIcon( new ImageIcon( Main.class
.getResource( "/org/img/menu-help.png" ) ) );
mnHelp.add( mntmControls );
JSeparator separator_1 = new JSeparator();
mnHelp.add( separator_1 );
JMenuItem mntmAbout = new JMenuItem( "About" );
mntmAbout.setMnemonic( 'g' );
mntmAbout.setIcon( new ImageIcon( Main.class
.getResource( "/org/img/menu-about.png" ) ) );
mnHelp.add( mntmAbout );
EDIT:
I made some experiments, and it turned out it's not a problem caused by something in my program, but in java or eclipse instead, because even the simplest program like the one whose code I'll paste here has the same problem: `
package testpack;
import java.awt.Dimension;
import javax.swing.*;
public class Main {
public static void main( String[] args ) {
JFrame jfr = new JFrame( "" );
jfr.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
JMenuBar jmb = new JMenuBar();
JMenu jm = new JMenu( "Hello" );
JMenuItem jmi = new JMenuItem( "Hi" );
jm.add( jmi );
jmb.add( jm );
jfr.setJMenuBar( jmb );
jfr.setMinimumSize( new Dimension( 400, 400 ) );
jfr.setVisible( true );
}
}
` ( this is the whole source )
I'm using Mint Cinnamon 13 and Eclipse 4.2. So is there anything I could do to fix the problem?