Top Description Fields Constructors Methods
org.eclipse.swt.awt

public Class SWT_AWT

extends Object
Class Inheritance
Imports
java.awt.*, .Canvas, java.awt.event.*, java.lang.reflect.*, org.eclipse.swt.*, org.eclipse.swt.graphics.*, .Point, .Rectangle, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*, org.eclipse.swt.widgets.*, .Composite

This class provides a bridge between SWT and AWT, so that it is possible to embed AWT components in SWT and vice versa.
Since
3.0
See Also
Swing/AWT snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv static String
EMBEDDED_FRAME_KEY

Key for looking up the embedded frame for a Composite using getData().

public static String
embeddedFrameClass

The name of the embedded Frame class.

pack-priv static boolean
pack-priv static boolean

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
pack-priv static final native long
public static Frame

Returns:

a java.awt.Frame the embedded frame or null.
getFrame
(Composite
the parent Composite of the java.awt.Frame
parent
)

Returns a java.awt.Frame which is the embedded frame associated with the specified composite.

pack-priv static final native Object
initFrame(long handle, String className)

pack-priv static synchronized void
pack-priv static synchronized void
public static Frame

Returns:

a java.awt.Frame to be the parent of the embedded AWT components
new_Frame
(final Composite
the parent Composite of the new java.awt.Frame
parent
)

Creates a new java.awt.Frame.

public static Shell

Returns:

a Shell to be the parent of the embedded SWT widgets
new_Shell
(final Display
the display for the new Shell
display
,
final Canvas
the parent java.awt.Canvas of the new Shell
parent
)

Creates a new Shell.

pack-priv static final native void
pack-priv static final native void
setDebug(Frame canvas, boolean debug)

pack-priv static final native void
synthesizeWindowActivation(Frame frame, boolean doActivate)

pack-priv static final native void
validateWithBounds(Frame frame, int x, int y, int w, int h)

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

EMBEDDED_FRAME_KEYback to summary
pack-priv static String EMBEDDED_FRAME_KEY

Key for looking up the embedded frame for a Composite using getData().

embeddedFrameClassback to summary
public static String embeddedFrameClass

The name of the embedded Frame class. The default class name for the platform will be used if null.

loadedback to summary
pack-priv static boolean loaded
swingInitializedback to summary
pack-priv static boolean swingInitialized

Constructor Detail

SWT_AWTback to summary
public SWT_AWT()

Method Detail

getAWTHandleback to summary
pack-priv static final native long getAWTHandle(Object canvas)
getFrameback to summary
public static Frame getFrame(Composite parent)

Returns a java.awt.Frame which is the embedded frame associated with the specified composite.

Parameters
parent:Composite

the parent Composite of the java.awt.Frame

Returns:Frame

a java.awt.Frame the embedded frame or null.

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
Since
3.2
initFrameback to summary
pack-priv static final native Object initFrame(long handle, String className)
initializeSwingback to summary
pack-priv static synchronized void initializeSwing()
loadLibraryback to summary
pack-priv static synchronized void loadLibrary()
new_Frameback to summary
public static Frame new_Frame(final Composite parent)

Creates a new java.awt.Frame. This frame is the root for the AWT components that will be embedded within the composite. In order for the embedding to succeed, the composite must have been created with the SWT.EMBEDDED style.

Important Note

As of JDK1.5, the embedded frame does not receive mouse events. When a lightweight component is added as a child of the embedded frame, the cursor does not change. In order to work around both these problems, it is strongly recommended that a heavyweight component such as java.awt.Panel be added to the frame as the root of all components.

Parameters
parent:Composite

the parent Composite of the new java.awt.Frame

Returns:Frame

a java.awt.Frame to be the parent of the embedded AWT components

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
  • ERROR_INVALID_ARGUMENT - if the parent Composite does not have the SWT.EMBEDDED style
Since
3.0
new_Shellback to summary
public static Shell new_Shell(final Display display, final Canvas parent)

Creates a new Shell. This Shell is the root for the SWT widgets that will be embedded within the AWT canvas.

Parameters
display:Display

the display for the new Shell

parent:Canvas

the parent java.awt.Canvas of the new Shell

Returns:Shell

a Shell to be the parent of the embedded SWT widgets

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the display is null
  • ERROR_NULL_ARGUMENT - if the parent is null
  • ERROR_INVALID_ARGUMENT - if the parent's peer is not created
Since
3.0
registerListenersback to summary
pack-priv static final native void registerListeners(Frame frame)
setDebugback to summary
pack-priv static final native void setDebug(Frame canvas, boolean debug)
synthesizeWindowActivationback to summary
pack-priv static final native void synthesizeWindowActivation(Frame frame, boolean doActivate)
validateWithBoundsback to summary
pack-priv static final native void validateWithBounds(Frame frame, int x, int y, int w, int h)