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

Add position parameter to Window.setLocationRelativeTo()

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • None
    • 6
    • client-libs
    • x86
    • windows_xp

      A DESCRIPTION OF THE REQUEST :
      Currently, setLocationRelativeTo() centers the window over the given component. There are many occasions where a window needs to be drawn exactly over an existing component, aligned with the leftmost edge of the component (eg tooltip unrolls of tree names, when the tree doesn't fit on screen), immediately to the right of or below the component (eg context help for a keyboard-selected text field) or any of various other relative positions.

      setLocationRelativeTo() should be overloaded to allow the user to specify where exactly the window should be positioned, and to indicate the individual cell (of a table) or item (in a tree or a list) within the component that the location is relative to.

      JUSTIFICATION :
      setLocationRelativeTo() can contain special handling for the native platform window controls, which are impossible to account for generally in a pure java application without manually determining which OS and window manager is being used, and what the metrics are for the dialog/frame border, window title, close box and any other window controls that may be shown as part of the window.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Add two overloads:

      void setLocationRelativeTo(Component c, WindowPosition p);

      where p is an enum representing the supported relative window positions (at minimum, LINE_START_OVERLAP, CENTER, LINE_END_ADJACENT, PAGE_END_ADJACENT), and o represents an offset into a component.

      Add overrides of this method in Dialog, Frame, JDialog and/or JFrame to handle native window widgets.

      Specifying the location within a component (as would be used for JComboBox entries, JList entries, JTree nodes and JTable cells) would need further work by the user in getting the Renderer/Editor component at a position within the tree/table, then calling setLocationRelativeTo() on that renderer/editor.
      ACTUAL -
      None of this is supported by the current API.

      CUSTOMER SUBMITTED WORKAROUND :
      Implement your own setLocationRelativeTo() methods, which hopefully will account for platform metrics correctly.
      ###@###.### 2005-03-08 18:02:39 GMT

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

              Created:
              Updated:
              Imported:
              Indexed: