JDK-4725596 : Bad side effect of javax.swing.adjustPopupLocationToFit = TRUE
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.4.1
  • Priority: P3
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_2000
  • CPU: x86
  • Submitted: 2002-08-02
  • Updated: 2002-09-13
  • Resolved: 2002-09-13
Related Reports
Duplicate :  
Description

Name: jk109818			Date: 08/02/2002


FULL PRODUCT VERSION :
java version "1.4.0"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-b92)
Java HotSpot(TM) Client VM (build 1.4.0-b92, mixed mode)

FULL OPERATING SYSTEM VERSION :
Microsoft Windows 2000 [Version 5.00.2195]

EXTRA RELEVANT SYSTEM CONFIGURATION :
screen resolution : 1280x1024, 16 bit color

A DESCRIPTION OF THE PROBLEM :
The property "javax.swing.adjustPopupLocationToFit=TRUE"
makes a problem.

When we click a menu on the menu bar,
some menu item is automatically chosen
but not displaying the pulldown menu
not clicking any menun item.


STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. run the following program( MenuBug )
2. click "menu" on the menu bar
3. some menu item is automatically chosen.

//--------------------- MenuBug.java
import javax.swing.*;
import java.awt.event.*;

class MenuBug extends JFrame implements ActionListener {

  static
  {
   
System.setProperty("javax.swing.adjustPopupLocationToFit",
"true");
  }

  MenuBug( String title ){
    super( title );
    JMenuBar jMenuBar = new JMenuBar();
    setJMenuBar( jMenuBar );
    JMenu jMenu = new JMenu( "menu" );
    jMenuBar.add( jMenu );

    JMenuItem[] item = new JMenuItem[30];
    for( int i=0 ; i<30 ; i++ ){
      item[i] = new JMenuItem( "command "+ i );
      item[i].addActionListener( this );
      jMenu.add( item[i] );
    }
  }
  public void actionPerformed( ActionEvent e ){
    JMenuItem item = (JMenuItem)e.getSource();
    String msg = item.getText() + " is invoked";
    JOptionPane.showMessageDialog( this, msg );
  }

  public static void main( String[] args ){
    JFrame frame = new MenuBug( "MenuBug" );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize( 300, 300 );
    frame.setLocation( 100, 500 );
    frame.setVisible( true );
  }
}
//---------------------------------------------


EXPECTED VERSUS ACTUAL BEHAVIOR :
Any menu item should be chosen when a user clicks a
menunitem on pulldown menu.

This bug can be reproduced always.

---------- BEGIN SOURCE ----------
import javax.swing.*;
import java.awt.event.*;

class MenuBug extends JFrame implements ActionListener {

  static
  {
    System.setProperty("javax.swing.adjustPopupLocationToFit", "true");
  }

  MenuBug( String title ){
    super( title );
    JMenuBar jMenuBar = new JMenuBar();
    setJMenuBar( jMenuBar );
    JMenu jMenu = new JMenu( "menu" );
    jMenuBar.add( jMenu );

    JMenuItem[] item = new JMenuItem[30];
    for( int i=0 ; i<30 ; i++ ){
      item[i] = new JMenuItem( "command "+ i );
      item[i].addActionListener( this );
      jMenu.add( item[i] );
    }
  }
  public void actionPerformed( ActionEvent e ){
    JMenuItem item = (JMenuItem)e.getSource();
    String msg = item.getText() + " is invoked";
    JOptionPane.showMessageDialog( this, msg );
  }

  public static void main( String[] args ){
    JFrame frame = new MenuBug( "MenuBug" );
    frame.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
    frame.setSize( 300, 300 );
    frame.setLocation( 100, 500 );
    frame.setVisible( true );
  }
}

---------- END SOURCE ----------

CUSTOMER WORKAROUND :
set "javax.swing.adjustPopupLocationToFit=false" stop this
problem
but this makes another problem.

When we set "javax.swing.adjustPopupLocationToFit=false"
we have the problem of popup menu
  Bug ID:4432432
(Review ID: 146259) 
======================================================================

Comments
EVALUATION Name: azR10139 Date: 09/13/2002 This bug caused by the same reason as bug 4711693. Suggested fix for bug 4711693 fixes this problem. ###@###.### 09/13/2002 ======================================================================
13-09-2002