Interface Window
-
public interface Window
Definition of an interface for describing windows in a platform independent way.
This interface is an abstraction of a typical window. It defines methods for querying and setting window related properties. For each supported GUI library (or platform) there will be an implementation that hides the specifics of window objects of that library. So application code can simply manipulate these objects through the methods provided here.
- Version:
- $Id: Window.java 205 2012-01-29 18:29:57Z oheger $
- Author:
- Oliver Heger
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
addMouseListener(FormMouseListener l)
Adds a listener for mouse events to this window.void
addWindowListener(WindowListener l)
Adds a window listener for this window.boolean
close(boolean force)
Closes this window.int
getHeight()
Returns the window's height.Window
getParentWindow()
Returns the (platform independent abstraction of) window's parent window.Object
getRootContainer()
Returns the window's root container.String
getTitle()
Returns the window's title.int
getWidth()
Returns the window's width.WindowClosingStrategy
getWindowClosingStrategy()
Returns the currentWindowClosingStrategy
of this window.Object
getWindowController()
Returns the controller object for this window.int
getXPos()
Returns the window's x position.int
getYPos()
Returns the window's y position.boolean
isVisible()
Returns a flag if this window is visible.void
open()
Opens the window.void
removeMouseListener(FormMouseListener l)
Removes the specified mouse listener from this window.void
removeWindowListener(WindowListener l)
Removes a window listener for this window.void
setBounds(int x, int y, int w, int h)
Allows to set the window's bounds.void
setTitle(String s)
Sets the window's title.void
setVisible(boolean f)
Sets the window's visible flag.void
setWindowClosingStrategy(WindowClosingStrategy windowClosingStrategy)
Sets theWindowClosingStrategy
for this window.
-
-
-
Method Detail
-
isVisible
boolean isVisible()
Returns a flag if this window is visible.- Returns:
- the visible flag
-
setVisible
void setVisible(boolean f)
Sets the window's visible flag. This method can be used to hide and later show the window again.- Parameters:
f
- the flag's value
-
open
void open()
Opens the window. This method must be called to make the window visible for the first time.
-
close
boolean close(boolean force)
Closes this window. This should cause all resources obtained by the window to be freed. After invocation, the window instance should not be used any longer. Theforce
parameter determines whether the window'sWindowClosingStrategy
is to be invoked: if set to false, theWindowClosingStrategy
is queried, and the window is only closed if permitted. Otherwise, the window is always closed. The return value indicates the success of the operation. A value of false means that the window could not be closed because theWindowClosingStrategy
prohibited this operation.- Parameters:
force
- a flag whether the window is to be closed unconditionally- Returns:
- a flag whether this operation was successful
-
getXPos
int getXPos()
Returns the window's x position.- Returns:
- the window's x position
-
getYPos
int getYPos()
Returns the window's y position.- Returns:
- the window's y position
-
getWidth
int getWidth()
Returns the window's width.- Returns:
- the window's width
-
getHeight
int getHeight()
Returns the window's height.- Returns:
- the window's height
-
setBounds
void setBounds(int x, int y, int w, int h)
Allows to set the window's bounds. This method can be called to position and/or resize the window.- Parameters:
x
- the new x positiony
- the new y positionw
- the new widthh
- the new height
-
getTitle
String getTitle()
Returns the window's title.- Returns:
- the title (can be null)
-
setTitle
void setTitle(String s)
Sets the window's title.- Parameters:
s
- the new title
-
getParentWindow
Window getParentWindow()
Returns the (platform independent abstraction of) window's parent window. For top level windows this method will return null.- Returns:
- the window's parent window
-
addWindowListener
void addWindowListener(WindowListener l)
Adds a window listener for this window.- Parameters:
l
- the listener to add
-
removeWindowListener
void removeWindowListener(WindowListener l)
Removes a window listener for this window.- Parameters:
l
- the listener to remove
-
getWindowClosingStrategy
WindowClosingStrategy getWindowClosingStrategy()
Returns the currentWindowClosingStrategy
of this window.- Returns:
- the
WindowClosingStrategy
; this can be null
-
setWindowClosingStrategy
void setWindowClosingStrategy(WindowClosingStrategy windowClosingStrategy)
Sets theWindowClosingStrategy
for this window. This object checks if a window can be closed.- Parameters:
windowClosingStrategy
- the newWindowClosingStrategy
-
getWindowController
Object getWindowController()
Returns the controller object for this window. The window's controller is a simple POJO provided by the application that can react on window or component events, thus acting as a typical controller.- Returns:
- the window's controller (can be null if no controller was specified when the window was created)
-
getRootContainer
Object getRootContainer()
Returns the window's root container. This container must be known if new components should be added to the window, especially during the builder process.- Returns:
- the window's root container
-
addMouseListener
void addMouseListener(FormMouseListener l)
Adds a listener for mouse events to this window. The listener is then informed about the standard mouse events supported by the platform-independentFormMouseListener
interface.- Parameters:
l
- the mouse listener to be added
-
removeMouseListener
void removeMouseListener(FormMouseListener l)
Removes the specified mouse listener from this window. If the listener was not registered, this method has no effect.- Parameters:
l
- the listener to remove
-
-