JDK-4176725 : Clicking frame border doesn't close open menus.
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.1.6
  • Priority: P5
  • Status: Closed
  • Resolution: Duplicate
  • OS: solaris_2.5.1
  • CPU: sparc
  • Submitted: 1998-09-28
  • Updated: 1998-09-30
  • Resolved: 1998-09-30
Related Reports
Duplicate :  
Description

Name: mf23781			Date: 09/28/98


The menu JMenuBar doesn't appear to work like ordinary menus. 
Clicking the mouse outside of the application area
(or on the frame border) does not dismiss the menu.

Behaviour occurs on 1.1.6 and 1.2 beta Solaris builds. Win32 appears OK.

Here is code to demonstrate the problem:

/**
 * MenuFrameTest.java

 * 1998 07 15
 * This code is for a very simple java application that demonstrates
 * an inconsistency between AIX and other platforms.  When a menu is
 * open and the user clicks on the border of the frame, the menu
 * should close.  The menu closes correctly on other platforms but
 * does not close with JDK 1.1.6 using Swing 1.0.2 on AIX.

 */


import com.sun.java.swing.*;

import java.awt.*;

import
java.awt.event.*;



public class MenuFrameTest extends JFrame

{


  static MenuFrameTest mftframe;

  static String        dataStr[];


  public MenuFrameTest( String title, int width, int height )

  {
    super( title );

    JPanel jpContent = new JPanel();
    JLabel jlContent0 = new JLabel( dataStr[0], JLabel.CENTER );
    JLabel jlContent1 = new JLabel( dataStr[1], JLabel.CENTER );
    JLabel jlContent2 = new JLabel( dataStr[2], JLabel.CENTER );
    jpContent.setLayout( new GridLayout(3,1) );
    jpContent.add( jlContent0 );

    jpContent.add( jlContent1 );
    jpContent.add( jlContent2 );

    JMenuBar menuBar = new JMenuBar();
    JMenu file = (JMenu) menuBar.add( new JMenu("File") );
    file.setMnemonic( 'F' );

    JMenuItem jmi;
    jmi = (JMenuItem) file.add( new JMenuItem("Dummy1") );
    jmi = (JMenuItem) file.add( new JMenuItem("Dummy2") );
    jmi = (JMenuItem) file.add( new JMenuItem("Dummy3") );
    file.add( new JSeparator() );
    jmi = (JMenuItem) file.add( new JMenuItem("Exit") );
    jmi.setMnemonic( 'x' );

    jmi.addActionListener( new
ActionListener()
      { public void actionPerformed(ActionEvent e) { System.exit(0); } }
);

    getContentPane().add( menuBar, BorderLayout.NORTH );
    getContentPane().add( jpContent, BorderLayout.CENTER );
    addWindowListener( new WindowAdapter()
      { public void windowClosing(WindowEvent e) {System.exit(0);} } );
    setSize( width, height );

    setVisible( true );

  }


  public static void main( String args[] )

  {
    dataStr = new String[3];
    dataStr[0] = new String( "When you click on the file menu so that the"
);
    dataStr[1] = new String( "menu opens and then click on the border of"
);

    dataStr[2] = new String( "the JFrame, the menu does not close." );
    mftframe = new MenuFrameTest( "Menu Frame Test", 350, 130 );

  }



}

======================================================================

Comments
EVALUATION This is expected behavior, until native grab is available from Java. georges.saab@Eng 1998-09-30
30-09-1998