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

JMenu not displayed correctly when number of JMenuItems is huge

XMLWordPrintable

    • generic, x86
    • generic, solaris_2.6, windows_2000

      Name: gm110360 Date: 10/23/2001


      java version "1.4.0-beta3"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta3-b83)
      Java HotSpot(TM) Client VM (build 1.4.0-beta3-b83, mixed mode)

      When there are more JMenuItems in a JMenu than fit on the screen, the display
      behavior is strange. Swing should then display the JMenuItems in more than one
      column (like Windows does). Another bug is that the menu is not centered in the
      screen if it does not fit on the screen.

      import java.awt.*;
      import javax.swing.*;
      public class Menu {
         public static void main (String args[]) {try{
            final JFrame frame = new JFrame("Test");
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.setSize(200,200);
            JMenuBar jmb=new JMenuBar();
            JMenu jm=new JMenu("Test Menu");
            for(int i=0; i<100; i++)
               jm.add(new JMenuItem("Test menu item " + i));
            jmb.add(jm);
            frame.getContentPane().add(jmb, BorderLayout.NORTH);
            frame.getContentPane().add(new JLabel("content"), BorderLayout.CENTER);
            frame.setVisible(true);}
            catch(Exception e)
            {e.printStackTrace();}
         }
      }
      (Review ID: 134251)
      ======================================================================
      ###@###.### 10/18/04 14:45 GMT

            Unassigned Unassigned
            gmanwanisunw Girish Manwani (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Imported:
              Indexed: