Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4725596

Bad side effect of javax.swing.adjustPopupLocationToFit = TRUE

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P3
    • Resolution: Duplicate
    • Affects Version/s: 1.4.1
    • Fix Version/s: None
    • Component/s: client-libs
    • Labels:

      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)
      ======================================================================

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                kizune Alexander Zuev
                Reporter:
                jkimsunw Jeffrey Kim (Inactive)
              • Votes:
                0 Vote for this issue
                Watchers:
                0 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved:
                  Imported:
                  Indexed: