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

Menu items can be lost

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not an Issue
    • Icon: P4 P4
    • None
    • 2.1, 1.1.1, 1.1.6
    • client-libs
    • None
    • generic, x86
    • other, solaris_2.6, windows_nt

      The following code demonstrates a problem with displaying large menus.

      import java.awt.*;
      import java.awt.event.*;


      public class MenuTest extends Frame {
      MenuBar menuTest;

          public MenuTest() {
      super();
      setSize(200,200);
      this.addWindowListener(new WindowAdapter() { // begin anon
      public void windowClosing(WindowEvent e) {
      System.exit(0);
      } // windowClosing
      } ); // end anon
      menuTest = createMenuBar();

          }
      // basic instantiation
          
          public static void main(String argv[]) {
      MenuTest testFrame = new MenuTest();
      testFrame.setMenuBar(testFrame.menuTest);
      testFrame.setVisible(true);
      }

          MenuBar createMenuBar() {
      // MenuBar
      MenuBar menuBar = new MenuBar();

      MenuItem mi;

      // File Menu
      Menu file = (Menu) menuBar.add(new Menu("File"));
              mi = (MenuItem) file.add(new MenuItem("About"));
              mi = (MenuItem) file.add(new MenuItem("Open"));
      mi.setEnabled(false);
              mi = (MenuItem) file.add(new MenuItem("Save"));
      mi.setEnabled(false);
              mi = (MenuItem) file.add(new MenuItem("Save As..."));
      mi.setEnabled(false);
              
              mi = (MenuItem) file.add(new MenuItem("Exit"));
              
      mi.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
      System.exit(0);
      }
      });


      // Options Menu
      Menu options = (Menu) menuBar.add(new Menu("100 Items"));
      for (int i = 1; i<100; i++)
      {
      mi = (MenuItem) options.add(new MenuItem("choice " + i));
      }


      return menuBar;
          }

      }

      Added by nick.rodin@eng, 1998-10-19:

      I have tested this example with 1.1.6, 1.1.7, and 1.2 with the same results.

            son Oleg Sukhodolsky (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: