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

Popup menu direction incorrect for very wide menus

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 1.4.0
    • 1.3.0, 1.3.1
    • client-libs
    • beta2
    • generic
    • generic



      Name: skT45625 Date: 06/01/2000


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


      The direction in which a submenu pops up is still incorrect in JDK1.3. The
      problem occurs if:

      1- the width of the submenu is greater than 50% of the screen width, and
      2- the parent menu is located in the first half of the screen, and
      3- the submenu doesn't fit to the right of the parent menu

      This causes the submenu to pop up to the left of the parent menu, which will
      actually make it look worse than if the menu had been popped up to the right.

      Example:

      Say the screen width is 1000 pixels, the parent menu is located at x=400 on the
      screen, the parent menu is 100 pixels wide, and the submenu is 700 pixels wide.

      The submenu doesn't fit to the right of the parent menu (400 + 100 + 700 = 1300
      < 1000), so it's popped up to the left. However, there are only 400 pixels
      avaiable on the left, causing 300 pixels to be truncated from the submenu,
      whereas popping up the submenu to the right would have truncated only 200
      pixels (1000 - 400 - 100 = 500 pixels were available to the right).

      Also, because the submenu is popped up to the left of the parent menu, the
      start of the menu items get truncated, which is much worse than having the end
      of the menu items chopped off.

      This can be fixed by changing the code in JMenu.getPopupMenuOrigin().


      ###@###.### 2000-06-01
      Sorry I don't have the time to create a test program. The problem is
      obvious if you look at the source code of JMenu.getPopupMenuOrigin()
      line 340:

      // We are a submenu (pull-right)
      if( SwingUtilities.isLeftToRight(this) ) {
        // First determine x:
        if (position.x+s.width + pmSize.width < screenSize.width) {
          x = s.width; // Prefer placement to the right
        } else {
          /*** Bug here ***/
          x = 0-pmSize.width; // Otherwise place to the left
        }
      } else {
      ...

      Line 340 should be replaced with:

      if (screenSize.width - position.x + s.width < position.x) {
          x = 0-pmSize.width; // Prefer placement to the left
      } else {
          x = s.width; // Prefer placement to the right
      }

      Same problem and similar fix lines 347, 354, 364 and 371.
      (Review ID: 105571)
      ======================================================================

            peterz Peter Zhelezniakov
            skondamasunw Suresh Kondamareddy (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: