|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectswingintegration.example.AwtEnvironment
public final class AwtEnvironment
An environment to enable the proper display of AWT/Swing windows within a SWT or RCP
application. This class extends the base Eclipse SWT/AWT integration
support by
This class is most helpful to applications which create new AWT/Swing windows (e.g. dialogs) rather
than those which embed AWT/Swing components in SWT windows. For support specific to embedding
AWT/Swing components see EmbeddedSwingComposite
.
There is at most one instance of this class per SWT
Display
. In almost all applications
this means that there is exactly one instance for the entire application. In fact, the
current implementation always limits the number of instances to exactly one.
An instance of this class can be obtained with the static
getInstance(Display)
method.
Method Summary | |
---|---|
Frame |
createDialogParentFrame()
Creates an AWT frame suitable as a parent for AWT/Swing dialogs. |
Frame |
createDialogParentFrame(Shell parent)
Creates an AWT frame suitable as a parent for AWT/Swing dialogs. |
static AwtEnvironment |
getInstance(Display display)
Returns the single instance of AwtEnvironment for the given display. |
void |
invokeAndBlockSwt(Runnable runnable)
Invokes the given runnable in the AWT event thread while blocking user input on the SWT event thread. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static AwtEnvironment getInstance(Display display)
The first call to this method must occur before any AWT/Swing APIs are called.
The current implementation limits the number of instances of
AwtEnvironment to one. If this method is called with a display different
to one used on a previous call, UnsupportedOperationException
is
thrown.
display
- the non-null SWT display
IllegalArgumentException
- UnsupportedOperationException
- -
on attempt to use multiple displays.public void invokeAndBlockSwt(Runnable runnable)
This method is useful for displayng modal AWT/Swing dialogs from the SWT event thread. The modal AWT/Swing dialog will always block input across the whole application, but not until it appears. By calling this method, it is guaranteed that SWT input is blocked immediately, even before the AWT/Swing dialog appears.
To avoid unnecessary flicker, AWT/Swing dialogs should have their parent
set to a frame returned by createDialogParentFrame()
.
This method must be called from the SWT event thread.
runnable
- the code to schedule on the AWT event thread
IllegalArgumentException
- SWTException
- public Frame createDialogParentFrame()
This method must be called from the SWT event thread. There must be an active shell associated with the environment's display.
The created frame is a non-visible child of the active shell and will be disposed when that shell is disposed.
See createDialogParentFrame(Shell)
for more details.
Frame
to be used for parenting dialogs
SWTException
- IllegalStateException
- if the current display has no shellspublic Frame createDialogParentFrame(Shell parent)
This method must be called from the SWT event thread. There must be an active shell associated with the environment's display.
The created frame is a non-visible child of the given shell and will be disposed when that shell is disposed.
This method is useful for creating a frame to parent any AWT/Swing
dialogs created for use inside a SWT application. A modal AWT/Swing
dialogs will flicker less if its parent is set to the returned frame
rather than to null or to an independently created Frame
.
Frame
to be used for parenting dialogs
SWTException
- IllegalStateException
- if the current display has no shells
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |