Package jmri.util
Class PlaceWindow
- java.lang.Object
-
- jmri.util.PlaceWindow
-
- All Implemented Interfaces:
InstanceManagerAutoDefault
public class PlaceWindow extends java.lang.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 Summary
Fields Modifier and Type Field Description (package private) static java.awt.GraphicsEnvironment
_environ
(package private) static java.awt.Dimension[]
_screenSize
(package private) static java.awt.Dimension
_totalScreenDim
-
Constructor Summary
Constructors Constructor Description PlaceWindow()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static PlaceWindow
getDefault()
int
getScreenNum(java.awt.Window window)
In a possibly multi-monitor environment, find the screen displaying the window and return its dimensions.java.awt.Dimension
getScreenSize(int screenNum)
java.awt.Point
nextTo(java.awt.Window parent, java.awt.Component comp, java.awt.Window target)
Find the best place to position the target window next to the component but not obscuring it.
-
-
-
Field Detail
-
_environ
static java.awt.GraphicsEnvironment _environ
-
_screenSize
static java.awt.Dimension[] _screenSize
-
_totalScreenDim
static java.awt.Dimension _totalScreenDim
-
-
Constructor Detail
-
PlaceWindow
public PlaceWindow()
-
-
Method Detail
-
getDefault
public static PlaceWindow getDefault()
-
getScreenNum
public int getScreenNum(java.awt.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 java.awt.Dimension getScreenSize(int screenNum)
-
nextTo
public java.awt.Point nextTo(java.awt.Window parent, java.awt.Component comp, java.awt.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 Componentcomp
- 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.
-
-