Package jmri.util

Class PlaceWindow

java.lang.Object
jmri.util.PlaceWindow
All Implemented Interfaces:
InstanceManagerAutoDefault

public class PlaceWindow extends Object implements InstanceManagerAutoDefault
Position a Window relative to a component in another window so as to not obscure a component in that window. Typically, the Component is being edited by actions done in the target Window.\p Note the assumption in multiple screen environments is the screens are configured horizontally.
Since:
4.13.1
  • Field Details

  • Constructor Details

  • Method Details

    • getDefault

      public static PlaceWindow getDefault()
    • getScreenNum

      public int getScreenNum(Window window)
      In a possibly multi-monitor environment, find the screen displaying the window and return its dimensions. \p getLocation() and getLocationOnScreen() return the same Point which has coordinates in the total display area, i.e. all screens combined. Note DefaultScreen is NOT this total combined display area. We assume monitors are aligned horizontally - at least this is the only configuration possible from Windows settings.
      Parameters:
      window - a window
      Returns:
      Screen number of window location
    • getScreenSize

      public Dimension getScreenSize(int screenNum)
    • nextTo

      public Point nextTo(Window parent, Component comp, Window target)
      Find the best place to position the target window next to the component but not obscuring it. Positions target to the Left, Right, Below or Above. Tries in that order to keep target within the parent window. If not possible, tries to keep the target window within the parent's screen. Failing that, will minimize the amount the target window is off screen. The method guarantees a non-null component will not be obscured.\p If the component is null, the target window is placed beside the parent window, to the Left, Right, Below or Above it.\b Should be called after target is packed and before target is set visible.
      Parameters:
      parent - Window containing the Component
      comp - Component contained in the parent Window. May be null.
      target - a popup or some kind of window associated with the component
      Returns:
      the location Point to open the target window.