Interface Window
-
public interface WindowDefinition 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 voidaddMouseListener(FormMouseListener l)Adds a listener for mouse events to this window.voidaddWindowListener(WindowListener l)Adds a window listener for this window.booleanclose(boolean force)Closes this window.intgetHeight()Returns the window's height.WindowgetParentWindow()Returns the (platform independent abstraction of) window's parent window.ObjectgetRootContainer()Returns the window's root container.StringgetTitle()Returns the window's title.intgetWidth()Returns the window's width.WindowClosingStrategygetWindowClosingStrategy()Returns the currentWindowClosingStrategyof this window.ObjectgetWindowController()Returns the controller object for this window.intgetXPos()Returns the window's x position.intgetYPos()Returns the window's y position.booleanisVisible()Returns a flag if this window is visible.voidopen()Opens the window.voidremoveMouseListener(FormMouseListener l)Removes the specified mouse listener from this window.voidremoveWindowListener(WindowListener l)Removes a window listener for this window.voidsetBounds(int x, int y, int w, int h)Allows to set the window's bounds.voidsetTitle(String s)Sets the window's title.voidsetVisible(boolean f)Sets the window's visible flag.voidsetWindowClosingStrategy(WindowClosingStrategy windowClosingStrategy)Sets theWindowClosingStrategyfor 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. Theforceparameter determines whether the window'sWindowClosingStrategyis to be invoked: if set to false, theWindowClosingStrategyis 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 theWindowClosingStrategyprohibited 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 currentWindowClosingStrategyof this window.- Returns:
- the
WindowClosingStrategy; this can be null
-
setWindowClosingStrategy
void setWindowClosingStrategy(WindowClosingStrategy windowClosingStrategy)
Sets theWindowClosingStrategyfor 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-independentFormMouseListenerinterface.- 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
-
-