public interface Window extends NativeWindow, WindowClosingProtocol, ScalableSurface
One use case is GLWindow
, which delegates
window operation to an instance of this interface while providing OpenGL
functionality.
All values of this interface are represented in window units, if not stated otherwise.
NativeWindow.getX()
and NativeWindow.getY()
. insets
, i.e. window decoration.NativeWindow
and Screen
.
Custom window icons can be defined via system property newt.window.icons
,
which shall contain a list of PNG icon locations from low- to high-resolution,
separated by one whitespace or one comma character.
The location must be resolvable via classpath, i.e. shall reference a location within the jar file.
Example (our default):
-Dnewt.window.icons="newt/data/jogamp-16x16.png,newt/data/jogamp-32x32.png" -Djnlp.newt.window.icons="newt/data/jogamp-16x16.png,newt/data/jogamp-32x32.png"The property can also be set programmatically, which must happen before any NEWT classes are touched:
System.setProperty("newt.window.icons", "newt/data/jogamp-16x16.png, newt/data/jogamp-32x32.png");To disable even Jogamp's own window icons in favor of system icons, simply set a non-existing location, e.g.:
-Dnewt.window.icons="null,null"
Some of the methods specified here are lifecycle-heavy. That is, they are able
to destroy and/or reattach resources to/from the window. Because of this, the methods
are not safe to be called from EDT related threads. For example, it is not
safe for a method in an attached KeyListener
to call setFullscreen(boolean)
on a Window
directly. It is safe, however, for that method to spawn a background
worker thread which calls the method directly. The documentation for individual methods
indicates whether or not they are lifecycle-heavy.
Modifier and Type | Interface and Description |
---|---|
static interface |
Window.FocusRunnable |
static class |
Window.ReparentOperation
Reparenting operation types
|
WindowClosingProtocol.WindowClosingMode
Modifier and Type | Field and Description |
---|---|
static boolean |
DEBUG_IMPLEMENTATION |
static boolean |
DEBUG_KEY_EVENT |
static boolean |
DEBUG_MOUSE_EVENT |
static int |
REPARENT_HINT_BECOMES_VISIBLE
Reparenting hint (bitfield value): Claim window becomes visible after reparenting, which is important for e.g.
|
static int |
REPARENT_HINT_FORCE_RECREATION
Reparenting hint (bitfield value): Force destroy and hence
re-creating the window. |
static int |
STATE_BIT_ALWAYSONBOTTOM
Set if window is always on bottom, otherwise cleared.
|
static int |
STATE_BIT_ALWAYSONTOP
Set if window is always on top, otherwise cleared.
|
static int |
STATE_BIT_AUTOPOSITION
Hinting that no custom position has been set before first
visibility of this instance. |
static int |
STATE_BIT_CHILDWIN
Set if window is a child window, i.e.
|
static int |
STATE_BIT_FOCUSED
Set if window has the input focus, otherwise cleared.
|
static int |
STATE_BIT_FULLSCREEN
Set if window is in fullscreen mode, otherwise cleared.
|
static int |
STATE_BIT_MAXIMIZED_HORZ
Set if window is maximized horizontally, otherwise cleared.
|
static int |
STATE_BIT_MAXIMIZED_VERT
Set if window is maximized vertically, otherwise cleared.
|
static int |
STATE_BIT_POINTERCONFINED
Set if the pointer is confined to the window, otherwise cleared.
|
static int |
STATE_BIT_POINTERVISIBLE
Set if the pointer is visible when inside the window, otherwise cleared.
|
static int |
STATE_BIT_RESIZABLE
Set if window is resizable, otherwise cleared.
|
static int |
STATE_BIT_STICKY
Set if window is sticky, i.e.
|
static int |
STATE_BIT_UNDECORATED
Set if window has window decorations, otherwise cleared.
|
static int |
STATE_BIT_VISIBLE
Visibility of this instance.
|
static int |
STATE_MASK_ALWAYSONBOTTOM
Bitmask for
STATE_BIT_ALWAYSONBOTTOM , 64. |
static int |
STATE_MASK_ALWAYSONTOP
Bitmask for
STATE_BIT_ALWAYSONTOP , 32. |
static int |
STATE_MASK_AUTOPOSITION
Bitmask for
STATE_BIT_AUTOPOSITION , 2. |
static int |
STATE_MASK_CHILDWIN
Bitmask for
STATE_BIT_CHILDWIN , 4. |
static int |
STATE_MASK_FOCUSED
Bitmask for
STATE_BIT_FOCUSED , 8. |
static int |
STATE_MASK_FULLSCREEN
Bitmask for
STATE_BIT_FULLSCREEN , 2048. |
static int |
STATE_MASK_MAXIMIZED_HORZ
Bitmask for
STATE_BIT_MAXIMIZED_HORZ , 1024. |
static int |
STATE_MASK_MAXIMIZED_VERT
Bitmask for
STATE_BIT_MAXIMIZED_VERT , 512. |
static int |
STATE_MASK_POINTERCONFINED
Bitmask for
STATE_BIT_POINTERCONFINED , 8192. |
static int |
STATE_MASK_POINTERVISIBLE
Bitmask for
STATE_BIT_POINTERVISIBLE , 4096. |
static int |
STATE_MASK_RESIZABLE
Bitmask for
STATE_BIT_RESIZABLE , 256. |
static int |
STATE_MASK_STICKY
Bitmask for
STATE_BIT_STICKY , 128. |
static int |
STATE_MASK_UNDECORATED
Bitmask for
STATE_BIT_UNDECORATED , 16. |
static int |
STATE_MASK_VISIBLE
Bitmask for
STATE_BIT_VISIBLE , 1. |
static long |
TIMEOUT_NATIVEWINDOW
A 1s timeout while waiting for a native action response, ie
setVisible(boolean) . |
LOCK_SUCCESS, LOCK_SURFACE_CHANGED, LOCK_SURFACE_NOT_READY, LOCK_SURFACE_UNLOCKED
AUTOMAX_PIXELSCALE, IDENTITY_PIXELSCALE
Modifier and Type | Method and Description |
---|---|
boolean |
addChild(NativeWindow win) |
void |
addGestureHandler(GestureHandler gh)
Appends the given
GestureHandler to the end of the list. |
void |
addGestureHandler(int index,
GestureHandler gh)
Inserts the given
GestureHandler at the
specified position in the list. |
void |
addGestureListener(GestureHandler.GestureListener gl)
Appends the given
GestureHandler.GestureListener to the end of the list. |
void |
addGestureListener(int index,
GestureHandler.GestureListener gl)
Inserts the given
GestureHandler.GestureListener at the
specified position in the list. |
void |
addKeyListener(int index,
KeyListener l)
Inserts the given
KeyListener at the
specified position in the list. |
void |
addKeyListener(KeyListener l)
Appends the given
KeyListener to the end of
the list. |
void |
addMouseListener(int index,
MouseListener l)
Inserts the given
MouseListener at the
specified position in the list. |
void |
addMouseListener(MouseListener l)
Appends the given
MouseListener to the end of the list. |
void |
addWindowListener(int index,
WindowListener l)
Inserts the given
WindowListener at the
specified position in the list. |
void |
addWindowListener(WindowListener l)
Appends the given
WindowListener to the end of
the list. |
boolean |
areDefaultGesturesEnabled()
Return true if default
GestureHandler are enabled. |
void |
confinePointer(boolean confine)
Confine the pointer to this window, ie.
|
void |
destroy()
Destroys this window incl.
|
void |
enqueueEvent(boolean wait,
NEWTEvent event)
Enqueues a
NEWT event . |
Rectangle |
getBounds()
Returns a newly created
Rectangle containing window origin, NativeWindow.getX() & NativeWindow.getY() ,
and size, NativeWindow.getWidth() & NativeWindow.getHeight() , in window units. |
CapabilitiesImmutable |
getChosenCapabilities()
Gets an immutable set of chosen capabilities.
|
Window |
getDelegatedWindow()
If the implementation uses delegation, return the delegated
Window instance,
otherwise return this instance. |
KeyListener |
getKeyListener(int index) |
KeyListener[] |
getKeyListeners() |
MonitorDevice |
getMainMonitor()
|
MouseListener |
getMouseListener(int index)
Returns the
MouseListener from the list at the given index. |
MouseListener[] |
getMouseListeners()
Returns all
MouseListener |
float[] |
getPixelsPerMM(float[] ppmmStore)
Returns the pixels per millimeter of this window's
NativeSurface
according to the main monitor 's current mode 's
surface resolution . |
Display.PointerIcon |
getPointerIcon()
Returns the current
Display.PointerIcon , which maybe null for the default. |
CapabilitiesImmutable |
getRequestedCapabilities()
Gets an immutable set of requested capabilities.
|
Screen |
getScreen() |
int |
getStateMask()
Returns the current status mask of this instance.
|
String |
getStateMaskString()
Returns a string representation of the
current state mask . |
int |
getStatePublicBitCount()
Number of all public state bits.
|
int |
getStatePublicBitmask()
Bitmask covering all public state bits.
|
int |
getSupportedStateMask()
Returns the supported
state mask of the implementation. |
String |
getSupportedStateMaskString()
Returns a string representation of the
supported state mask . |
String |
getTitle() |
WindowListener |
getWindowListener(int index) |
WindowListener[] |
getWindowListeners() |
boolean |
isAlwaysOnBottom() |
boolean |
isAlwaysOnTop() |
boolean |
isChildWindow()
Returns
true if this window is a child window,
i.e. |
boolean |
isFullscreen() |
boolean |
isKeyboardVisible()
Return
true if the virtual on-screen keyboard is visible, otherwise false . |
boolean |
isMaximizedHorz() |
boolean |
isMaximizedVert() |
boolean |
isNativeValid() |
boolean |
isPointerConfined() |
boolean |
isPointerVisible() |
boolean |
isResizable() |
boolean |
isSticky() |
boolean |
isUndecorated() |
boolean |
isVisible() |
boolean |
removeChild(NativeWindow win) |
void |
removeGestureHandler(GestureHandler gh)
Removes the given
GestureHandler from the list. |
void |
removeGestureListener(GestureHandler.GestureListener gl)
Removes the given
GestureHandler.GestureListener from the list. |
void |
removeKeyListener(KeyListener l) |
void |
removeMouseListener(MouseListener l)
Removes the given
MouseListener from the list. |
void |
removeWindowListener(WindowListener l) |
Window.ReparentOperation |
reparentWindow(NativeWindow newParent,
int x,
int y,
int hints)
Change this window's parent window.
|
void |
requestFocus()
Request focus for this native window
|
void |
requestFocus(boolean wait)
Request focus for this native window
|
void |
runOnEDTIfAvail(boolean wait,
Runnable task) |
void |
sendWindowEvent(int eventType)
Send a
WindowEvent to all WindowListener . |
void |
setAlwaysOnBottom(boolean value)
Operation is ignored if this instance
is a child window . |
void |
setAlwaysOnTop(boolean value)
Operation is ignored if this instance
is a child window . |
CapabilitiesChooser |
setCapabilitiesChooser(CapabilitiesChooser chooser)
Set the CapabilitiesChooser to help determine the native visual type.
|
void |
setDefaultGesturesEnabled(boolean enable)
Enable or disable default
GestureHandler . |
void |
setFocusAction(Window.FocusRunnable focusAction)
Sets a
Window.FocusRunnable ,
which Window.FocusRunnable.run() method is executed before the native focus is requested. |
boolean |
setFullscreen(boolean fullscreen)
Enable or disable fullscreen mode for this window.
|
boolean |
setFullscreen(List<MonitorDevice> monitors)
Enable fullscreen mode for this window spanning across the given
MonitorDevice s
or across all MonitorDevice s. |
void |
setKeyboardFocusHandler(KeyListener l)
Sets a
KeyListener allowing focus traversal with a covered window toolkit like AWT. |
void |
setKeyboardVisible(boolean visible)
In case the platform supports or even requires a virtual on-screen keyboard,
this method shows or hide it depending on whether
visible is true
or false . |
void |
setMaximized(boolean horz,
boolean vert)
Operation is ignored if this instance
is a child window . |
void |
setPointerIcon(Display.PointerIcon pi) |
void |
setPointerVisible(boolean pointerVisible)
Makes the pointer visible or invisible.
|
void |
setPosition(int x,
int y)
Sets the location of the window's client area excluding insets (window decorations) in window units.
This call is ignored if in fullscreen mode. |
void |
setResizable(boolean value)
Operation is ignored if this instance
is a child window . |
void |
setSize(int width,
int height)
Sets the size of the window's client area in window units, excluding decorations.
|
void |
setSticky(boolean value)
Operation is ignored if this instance
is a child window . |
void |
setSurfaceSize(int pixelWidth,
int pixelHeight)
Sets the size of the window's surface in pixel units which claims the window's client area excluding decorations.
|
void |
setTitle(String title) |
void |
setTopLevelPosition(int x,
int y)
Sets the location of the top-level window inclusive insets (window decorations) in window units.
|
void |
setTopLevelSize(int width,
int height)
Sets the size of the top-level window including insets (window decorations) in window units.
|
void |
setUndecorated(boolean value) |
void |
setVisible(boolean visible)
Calls
setVisible(true, visible) ,
i.e. |
void |
setVisible(boolean wait,
boolean visible)
setVisible(..) makes the window and children visible if visible is true,
otherwise the window and children becomes invisible. |
void |
setWindowDestroyNotifyAction(Runnable r)
Set a custom action handling destruction issued by a
toolkit triggered window destroy
replacing the default destroy() action. |
void |
warpPointer(int x,
int y)
Moves the pointer to x/y relative to this window's origin in pixel units.
|
void |
windowRepaint(int x,
int y,
int width,
int height)
Trigger window repaint while passing the dirty region in pixel units.
|
getHeight, getInsets, getLocationOnScreen, getNativeSurface, getParent, getWidth, getWindowHandle, getX, getY, hasFocus
addSurfaceUpdatedListener, addSurfaceUpdatedListener, convertToPixelUnits, convertToWindowUnits, getDisplayHandle, getGraphicsConfiguration, getScreenIndex, getSurfaceHandle, getSurfaceHeight, getSurfaceLockOwner, getSurfaceWidth, isSurfaceLockedByOtherThread, lockSurface, removeSurfaceUpdatedListener, surfaceSwap, unlockSurface
surfaceUpdated
getDefaultCloseOperation, setDefaultCloseOperation
getCurrentSurfaceScale, getMaximumSurfaceScale, getMinimumSurfaceScale, getRequestedSurfaceScale, setSurfaceScale
static final boolean DEBUG_MOUSE_EVENT
static final boolean DEBUG_KEY_EVENT
static final boolean DEBUG_IMPLEMENTATION
static final long TIMEOUT_NATIVEWINDOW
setVisible(boolean)
.static final int STATE_BIT_VISIBLE
Native instance gets created at first visibility, following NEWT's lazy creation pattern.
Changing this state is lifecycle heavy.
Bit number 0.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_AUTOPOSITION
visibility
of this instance.
If kept false
at creation, this allows the WM to choose the top-level window position,
otherwise the custom position is being enforced.
Bit number 1.
Defaults to true
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_CHILDWIN
reparented
.
Otherwise bit is cleared, i.e. window is top-level.
Changing this state is lifecycle heavy.
Bit number 2.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_FOCUSED
Bit number 3.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_UNDECORATED
Bit number 4.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_ALWAYSONTOP
Bit number 5.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_ALWAYSONBOTTOM
Bit number 6.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_STICKY
Bit number 7.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_RESIZABLE
Bit number 8.
Defaults to true
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_MAXIMIZED_VERT
Bit number 9.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_MAXIMIZED_HORZ
Bit number 10.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_FULLSCREEN
Usually fullscreen mode implies STATE_BIT_UNDECORATED
,
however, an implementation is allowed to ignore this if unavailable.
Bit number 11.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_POINTERVISIBLE
Bit number 12.
Defaults to true
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_BIT_POINTERCONFINED
Bit number 13.
Defaults to false
.
getStateMask()
,
Constant Field Valuesstatic final int STATE_MASK_VISIBLE
STATE_BIT_VISIBLE
, 1.static final int STATE_MASK_AUTOPOSITION
STATE_BIT_AUTOPOSITION
, 2.static final int STATE_MASK_CHILDWIN
STATE_BIT_CHILDWIN
, 4.static final int STATE_MASK_FOCUSED
STATE_BIT_FOCUSED
, 8.static final int STATE_MASK_UNDECORATED
STATE_BIT_UNDECORATED
, 16.static final int STATE_MASK_ALWAYSONTOP
STATE_BIT_ALWAYSONTOP
, 32.static final int STATE_MASK_ALWAYSONBOTTOM
STATE_BIT_ALWAYSONBOTTOM
, 64.static final int STATE_MASK_STICKY
STATE_BIT_STICKY
, 128.static final int STATE_MASK_RESIZABLE
STATE_BIT_RESIZABLE
, 256.static final int STATE_MASK_MAXIMIZED_VERT
STATE_BIT_MAXIMIZED_VERT
, 512.static final int STATE_MASK_MAXIMIZED_HORZ
STATE_BIT_MAXIMIZED_HORZ
, 1024.static final int STATE_MASK_FULLSCREEN
STATE_BIT_FULLSCREEN
, 2048.static final int STATE_MASK_POINTERVISIBLE
STATE_BIT_POINTERVISIBLE
, 4096.static final int STATE_MASK_POINTERCONFINED
STATE_BIT_POINTERCONFINED
, 8192.static final int REPARENT_HINT_FORCE_RECREATION
re-creating
the window.static final int REPARENT_HINT_BECOMES_VISIBLE
int getStatePublicBitCount()
getStateMask()
int getStatePublicBitmask()
getStateMask()
int getStateMask()
getSupportedStateMask()
,
STATE_MASK_VISIBLE
,
STATE_MASK_AUTOPOSITION
,
STATE_MASK_CHILDWIN
,
STATE_MASK_FOCUSED
,
STATE_MASK_UNDECORATED
,
STATE_MASK_ALWAYSONTOP
,
STATE_MASK_ALWAYSONBOTTOM
,
STATE_MASK_STICKY
,
STATE_MASK_RESIZABLE
,
STATE_MASK_MAXIMIZED_VERT
,
STATE_MASK_MAXIMIZED_HORZ
,
STATE_MASK_FULLSCREEN
,
STATE_MASK_POINTERVISIBLE
,
STATE_MASK_POINTERCONFINED
String getStateMaskString()
current state mask
.int getSupportedStateMask()
state mask
of the implementation.
Implementation provides supported state mask
values at runtime
after native window creation, i.e. first visibility.
Please note that a window's size shall also be allowed to change, i.e. setSize(int, int)
.
Default value is STATE_MASK_VISIBLE
| STATE_MASK_FOCUSED
| STATE_MASK_FULLSCREEN
,
i.e. the minimum requirement for all implementations.
Before native window creation getStatePublicBitmask()
is returned,
i.e. it is assumed all features are supported.
Semantic of the supported state-mask bits (after native creation, i.e. 1st visibility):
STATE_MASK_VISIBLE
: Visibility
can be toggled. Minimum requirement.STATE_MASK_CHILDWIN
: Native window parenting
is supported.STATE_MASK_FOCUSED
: Window focus management
is supported. Minimum requirement.STATE_MASK_UNDECORATED
: Window decoration
can be toggled.STATE_MASK_ALWAYSONTOP
: Window can be set always-on-top
. STATE_MASK_ALWAYSONBOTTOM
: Window can be set always-on-bottom
. STATE_MASK_STICKY
: Window can be set sticky
.STATE_MASK_RESIZABLE
: Window resizability
can be toggled.STATE_MASK_MAXIMIZED_VERT
: Window can be maximized-vertically
. STATE_MASK_MAXIMIZED_HORZ
: Window can be maximized-horizontally
. STATE_MASK_FULLSCREEN
: Window fullscreen
can be toggled. STATE_MASK_POINTERVISIBLE
: Window pointer visibility
can be toggled. STATE_MASK_POINTERCONFINED
: Window pointer can be confined
. getStateMask()
String getSupportedStateMaskString()
supported state mask
.boolean isNativeValid()
setVisible(true)
, otherwise false.setVisible(boolean)
,
#destroy(boolean)
MonitorDevice getMainMonitor()
MonitorDevice
with the highest viewport
coverage
of this window.
If no coverage is detected the first MonitorDevice
is returned.
CapabilitiesChooser setCapabilitiesChooser(CapabilitiesChooser chooser)
chooser
- the new CapabilitiesChooserCapabilitiesImmutable getRequestedCapabilities()
CapabilitiesImmutable getChosenCapabilities()
void destroy()
Also iterates through this window's children and destroys them.
Visibility is set to false.
Method sends out pre-
and
post-
destruction events
to all of it's WindowListener
.
This method invokes Screen.removeReference()
after it's own destruction,
which will issue Screen.destroy()
if the reference count becomes 0.
This destruction sequence shall end up in Display.destroy()
, if all reference counts become 0.
The Window can be recreate via setVisible(true)
.
This method is lifecycle heavy.
destroy
in interface NativeWindow
destroy()
,
setVisible(boolean)
void setWindowDestroyNotifyAction(Runnable r)
void setVisible(boolean visible)
setVisible(true, visible)
,
i.e. blocks until the window becomes visible.
This method is lifecycle heavy.
void setVisible(boolean wait, boolean visible)
setVisible(..)
makes the window and children visible if visible
is true,
otherwise the window and children becomes invisible.
Native instance gets created at first visibility, following NEWT's lazy creation pattern.
If wait
is true, method blocks until window is visible
and valid
,
otherwise method returns immediately.
Zero size semantics are respected, see setSize(int,int)
:
if ( 0 == windowHandle && visible ) { this.visible = visible; if( 0 < width && 0 < height ) { createNative(); } } else if ( this.visible != visible ) { this.visible = visible; setNativeSizeImpl(); }
In case this window is a child window
and has a NativeWindow
parent,
setVisible(wait, true)
has no effect as long the parent's is not valid yet,
i.e. NativeWindow.getWindowHandle()
returns null
.
setVisible(wait, true)
shall be repeated when the parent becomes valid.
This method is lifecycle heavy.
STATE_BIT_VISIBLE
boolean isVisible()
Window getDelegatedWindow()
Window
instance,
otherwise return this
instance.boolean addChild(NativeWindow win)
boolean removeChild(NativeWindow win)
Rectangle getBounds()
Rectangle
containing window origin, NativeWindow.getX()
& NativeWindow.getY()
,
and size, NativeWindow.getWidth()
& NativeWindow.getHeight()
, in window units.float[] getPixelsPerMM(float[] ppmmStore)
NativeSurface
according to the main monitor
's current mode
's
surface resolution
.
Method takes the current surface-scale
and native surface-scale
into account, i.e.:
surfacePpMM = monitorPpMM * currentSurfaceScale / nativeSurfaceScale, with PpMM == pixel per millimeter
To convert the result to dpi, i.e. dots-per-inch, multiply both components with 25.4f
.
ppmmStore
- float[2] storage for the ppmm resultvoid setSize(int width, int height)
Zero size semantics are respected, see setVisible(boolean)
:
if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) { setVisible(false); } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) { setVisible(true); } else { // as expected .. }
This call is ignored if in fullscreen mode.
width
- of the window's client area in window unitsheight
- of the window's client area in window unitssetSurfaceSize(int, int)
,
setTopLevelSize(int, int)
,
NativeWindow.getInsets()
void setSurfaceSize(int pixelWidth, int pixelHeight)
In multiple monitor mode, setting the window's surface size in pixel units might not be possible due to unknown scale values of the target display. Hence re-setting the pixel unit size after window creation is recommended.
Zero size semantics are respected, see setVisible(boolean)
:
if ( visible && 0 != windowHandle && ( 0 ≥ width || 0 ≥ height ) ) { setVisible(false); } else if ( visible && 0 == windowHandle && 0 < width && 0 < height ) { setVisible(true); } else { // as expected .. }
This call is ignored if in fullscreen mode.
pixelWidth
- of the window's client area in pixel unitspixelHeight
- of the window's client area in pixel unitssetSize(int, int)
,
NativeWindow.getInsets()
void setTopLevelSize(int width, int height)
Note: Insets (if supported) are available only after the window is set visible and hence has been created.
width
- of the top-level window area in window unitsheight
- of the top-level window area in window unitssetSize(int, int)
,
NativeWindow.getInsets()
void setPosition(int x, int y)
x
- coord of the client-area's top left corner in window unitsy
- coord of the client-area's top left corner in window unitsNativeWindow.getInsets()
void setTopLevelPosition(int x, int y)
Note: Insets (if supported) are available only after the window is set visible and hence has been created.
This call is ignored if in fullscreen mode.x
- coord of the top-level left corner in window unitsy
- coord of the top-level left corner in window unitssetPosition(int, int)
,
NativeWindow.getInsets()
void setUndecorated(boolean value)
#STATE_BIT_UNDECORATED}
,
#STATE_MASK_UNDECORATED}
boolean isUndecorated()
#STATE_BIT_UNDECORATED}
,
#STATE_MASK_UNDECORATED}
void setAlwaysOnTop(boolean value)
Operation is ignored if this instance is a child window
.
#STATE_BIT_ALWAYSONTOP}
,
#STATE_MASK_ALWAYSONTOP}
boolean isAlwaysOnTop()
#STATE_BIT_ALWAYSONTOP}
,
#STATE_MASK_ALWAYSONTOP}
void setAlwaysOnBottom(boolean value)
Operation is ignored if this instance is a child window
.
#STATE_BIT_ALWAYSONBOTTOM}
,
#STATE_MASK_ALWAYSONBOTTOM}
boolean isAlwaysOnBottom()
#STATE_BIT_ALWAYSONBOTTOM}
,
#STATE_MASK_ALWAYSONBOTTOM}
void setResizable(boolean value)
Operation is ignored if this instance is a child window
.
#STATE_BIT_RESIZABLE}
,
#STATE_MASK_RESIZABLE}
boolean isResizable()
#STATE_BIT_RESIZABLE}
,
#STATE_MASK_RESIZABLE}
void setSticky(boolean value)
Operation is ignored if this instance is a child window
.
#STATE_BIT_STICKY}
,
#STATE_MASK_STICKY}
boolean isSticky()
#STATE_BIT_STICKY}
,
#STATE_MASK_STICKY}
void setMaximized(boolean horz, boolean vert)
Operation is ignored if this instance is a child window
.
#STATE_BIT_MAXIMIZED_HORZ}
,
#STATE_BIT_MAXIMIZED_VERT}
,
#STATE_MASK_MAXIMIZED_HORZ}
,
#STATE_MASK_MAXIMIZED_VERT}
boolean isMaximizedVert()
#STATE_BIT_MAXIMIZED_VERT}
,
#STATE_MASK_MAXIMIZED_VERT}
boolean isMaximizedHorz()
#STATE_BIT_MAXIMIZED_HORZ}
,
#STATE_MASK_MAXIMIZED_HORZ}
void setTitle(String title)
String getTitle()
boolean isPointerVisible()
setPointerVisible(boolean)
void setPointerVisible(boolean pointerVisible)
pointerVisible
- defaults to true
for platforms w/ visible pointer,
otherwise defaults to true
, eg. Android.confinePointer(boolean)
Display.PointerIcon getPointerIcon()
Display.PointerIcon
, which maybe null
for the default.#setPointerIcon(PointerIcon)
void setPointerIcon(Display.PointerIcon pi)
pi
- Valid Display.PointerIcon
reference or null
to reset the pointer icon to default.Display.PointerIcon
,
Display.createPointerIcon(com.jogamp.common.util.IOUtil.ClassResources, int, int)
boolean isPointerConfined()
confinePointer(boolean)
void confinePointer(boolean confine)
Before jailing the mouse pointer, the window request the focus and the pointer is centered in the window.
In combination w/ warpPointer(int, int)
and maybe setPointerVisible(boolean)
a simple mouse
navigation can be realized.
confine
- defaults to false
.void warpPointer(int x, int y)
x
- relative pointer x position within this window in pixel unitsy
- relative pointer y position within this window in pixel unitsconfinePointer(boolean)
Window.ReparentOperation reparentWindow(NativeWindow newParent, int x, int y, int hints)
In case the old parent is not null and a Window,
this window is removed from it's list of children.
In case the new parent is not null and a Window,
this window is added to it's list of children.
This method is lifecycle heavy.
newParent
- The new parent NativeWindow. If null, this Window becomes a top level window.x
- new top-level position in window units, use -1 for default position.y
- new top-level position in window units, use -1 for default position.hints
- May contain hints (bitfield values) like REPARENT_HINT_FORCE_RECREATION
or REPARENT_HINT_BECOMES_VISIBLE
.boolean isChildWindow()
true
if this window is a child window,
i.e. has been reparented
.
Otherwise return false
, i.e. this window is a top-level window.
boolean setFullscreen(boolean fullscreen)
Fullscreen mode is established on the main monitor
.
This method is lifecycle heavy.
fullscreen
- enable or disable fullscreen modesetFullscreen(List)
,
isFullscreen()
boolean setFullscreen(List<MonitorDevice> monitors)
MonitorDevice
s
or across all MonitorDevice
s.
Disable fullscreen via setFullscreen(boolean)
.
This method is lifecycle heavy.
monitors
- if null
fullscreen will be spanned across all MonitorDevice
s,
otherwise across the given list of MonitorDevice
.setFullscreen(boolean)
,
isFullscreen()
boolean isFullscreen()
void setFocusAction(Window.FocusRunnable focusAction)
Window.FocusRunnable
,
which Window.FocusRunnable.run()
method is executed before the native focus is requested.
This allows notifying a covered window toolkit like AWT that the focus is requested, hence focus traversal can be made transparent.
void setKeyboardFocusHandler(KeyListener l)
KeyListener
allowing focus traversal with a covered window toolkit like AWT.
The KeyListener
methods are invoked prior to all other KeyListener
's
allowing to suppress the KeyEvent
via the NEWTEvent.consumedTag
and to perform focus traversal with a 3rd party toolkit.
The KeyListener
methods are not invoked for auto-repeat
events.
l
- void requestFocus()
The request is handled on this Window EDT and blocked until finished.
requestFocus(boolean)
void requestFocus(boolean wait)
The request is handled on this Window EDT.
wait
- true if waiting until the request is executed, otherwise falserequestFocus()
void windowRepaint(int x, int y, int width, int height)
x
- dirty-region y-pos in pixel unitsy
- dirty-region x-pos in pixel unitswidth
- dirty-region width in pixel unitsheight
- dirty-region height in pixel unitsvoid enqueueEvent(boolean wait, NEWTEvent event)
NEWT event
.wait
- Passing true
will block until the event has been processed, otherwise method returns immediately.event
- The event
to enqueue.void runOnEDTIfAvail(boolean wait, Runnable task)
void sendWindowEvent(int eventType)
WindowEvent
to all WindowListener
.eventType
- a WindowEvent
type, e.g. WindowEvent.EVENT_WINDOW_REPAINT
.void addWindowListener(WindowListener l)
WindowListener
to the end of
the list.void addWindowListener(int index, WindowListener l) throws IndexOutOfBoundsException
WindowListener
at the
specified position in the list.index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1void removeWindowListener(WindowListener l)
WindowListener getWindowListener(int index)
WindowListener[] getWindowListeners()
void setKeyboardVisible(boolean visible)
visible
is true
or false
.
One known platform where NEWT supports this feature is Android
.
boolean isKeyboardVisible()
true
if the virtual on-screen keyboard is visible, otherwise false
.
Currently on Android
, the only supported platform right now,
there is no way to reliably be notified of the current keyboard state.
It would be best, if your code does not rely on this information.
setKeyboardVisible(boolean)
void addKeyListener(KeyListener l)
KeyListener
to the end of
the list.void addKeyListener(int index, KeyListener l)
KeyListener
at the
specified position in the list.index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1void removeKeyListener(KeyListener l)
KeyListener getKeyListener(int index)
KeyListener[] getKeyListeners()
void addMouseListener(MouseListener l)
MouseListener
to the end of the list.void addMouseListener(int index, MouseListener l)
MouseListener
at the
specified position in the list.index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1void removeMouseListener(MouseListener l)
MouseListener
from the list.MouseListener getMouseListener(int index)
MouseListener
from the list at the given index.MouseListener[] getMouseListeners()
MouseListener
void setDefaultGesturesEnabled(boolean enable)
GestureHandler
. Default is enabled.boolean areDefaultGesturesEnabled()
GestureHandler
are enabled.void addGestureHandler(GestureHandler gh)
GestureHandler
to the end of the list.void addGestureHandler(int index, GestureHandler gh)
GestureHandler
at the
specified position in the list.index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1void removeGestureHandler(GestureHandler gh)
GestureHandler
from the list.void addGestureListener(GestureHandler.GestureListener gl)
GestureHandler.GestureListener
to the end of the list.void addGestureListener(int index, GestureHandler.GestureListener gl)
GestureHandler.GestureListener
at the
specified position in the list.index
- Position where the listener will be inserted.
Should be within (0 <= index && index <= size()).
An index value of -1 is interpreted as the end of the list, size().l
- The listener object to be insertedIndexOutOfBoundsException
- If the index is not within (0 <= index && index <= size()), or -1void removeGestureListener(GestureHandler.GestureListener gl)
GestureHandler.GestureListener
from the list.Copyright 2010 JogAmp Community.