org.eclipse.swt.widgets
Class Display

java.lang.Object
  |
  +--org.eclipse.swt.graphics.Device
        |
        +--org.eclipse.swt.widgets.Display

public class Display
extends Device


Constructor Summary
Display()
           
 
Method Summary
 void addListener(int eventType, Listener listener)
          Add a new listener to the list of registered listeners of the Display object which listens to the specified event type.
 void dispose()
          Disposes operating system resources associated with the receiver.
 Rectangle getBounds()
          Returns a rectangle describing the receiver's size and location.
 Rectangle getClientArea()
          Returns the dimension of the Displays client area.
static Display getDefault()
          Returns the default Display.
 Color getSystemColor(int id)
          Returns a matching color for the given system color.
 boolean readAndDispatch()
          Reads an event from the operating system's event queue, dispatches it appropriately, and returns true if there is potentially more work to do, or false if the caller can sleep until another event is placed on the event queue.
 boolean sleep()
          Causes the user interface thread to sleep (that is, to be put in a state where it does not consume CPU cycles) until an event is received or it is otherwise awakened.
 void timerExec(int millis, Runnable runnable)
          Causes the run() method of the specified Runnable to be invoked by the user interface (UI) thread after the specified number of milliseconds have elapsed.
 
Methods inherited from class org.eclipse.swt.graphics.Device
isDisposed
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, toString
 

Constructor Detail

Display

public Display()
Method Detail

addListener

public void addListener(int eventType,
                        Listener listener)
Add a new listener to the list of registered listeners of the Display object which listens to the specified event type. When events targeting this display object of the appropriate type are received, the message will be sent to the associated Listener function (its handleEvent is called), as defined in the Listener interface.

Parameters:
eventType - the type of the event to be listened for
listener - the Listener to be invoked when the event occurs

dispose

public void dispose()
Disposes operating system resources associated with the receiver. After this method has been invoked, the receiver will answer true on the isDisposed() method.

Specified by:
dispose in class Device

getBounds

public Rectangle getBounds()
Returns a rectangle describing the receiver's size and location. Example: x1,y1=0,0 +--------------------+ | | | | height=1050 | | +--------------------+ x2,y2=1399,1049 width=1400

Returns:
the bounding rectangle {x1,y1,width,height}
Throws:
SWTException -
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed

getClientArea

public Rectangle getClientArea()
Returns the dimension of the Displays client area.

Returns:
Rectangle object with the dimension

getDefault

public static Display getDefault()
Returns the default Display.

Returns:
the default display

getSystemColor

public Color getSystemColor(int id)
Returns a matching color for the given system color. The color constant should be one of the values specified in class SWT. Any value other than one of the SWT color constants will result in the color black.

Parameters:
id - the color constant
Returns:
the matching color
See Also:
SWT

readAndDispatch

public boolean readAndDispatch()
Reads an event from the operating system's event queue, dispatches it appropriately, and returns true if there is potentially more work to do, or false if the caller can sleep until another event is placed on the event queue.

Returns:
true if events are pending

sleep

public boolean sleep()
Causes the user interface thread to sleep (that is, to be put in a state where it does not consume CPU cycles) until an event is received or it is otherwise awakened.

Returns:
true if an event requiring dispatching was placed on the queue

timerExec

public void timerExec(int millis,
                      Runnable runnable)
Causes the run() method of the specified Runnable to be invoked by the user interface (UI) thread after the specified number of milliseconds have elapsed. If milliseconds is less than zero, the Runnable is not executed.

Parameters:
millis - the delay before the Runnable is started
runnable - object to be invoked
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the runnable is null
SWTException -
  • ERROR_DEVICE_DISPOSED - if the receiver has been disposed