# Class SWT_AWT

java.lang.Object
org.eclipse.swt.awt.SWT_AWT

public class SWT_AWT extends Object
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

Fields
Modifier and Type
Field
Description
`static String`
`embeddedFrameClass`
The name of the embedded Frame class.

## Constructor Summary

Constructors
Constructor
Description
`SWT_AWT()`

## Method Summary

Modifier and Type
Method
Description
`static Frame`
`getFrame(Composite parent)`
Returns a `java.awt.Frame` which is the embedded frame associated with the specified composite.
`static Frame`
`new_Frame(Composite parent)`
Creates a new `java.awt.Frame`.
`static Shell`
`new_Shell(Display display, Canvas parent)`
Creates a new `Shell`.

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### embeddedFrameClass

public static String embeddedFrameClass
The name of the embedded Frame class. The default class name for the platform will be used if `null`.

## Constructor Details

### SWT_AWT

public SWT_AWT()

## Method Details

### getFrame

public static Frame getFrame(Composite parent)
Returns a `java.awt.Frame` which is the embedded frame associated with the specified composite.

Parameters:
  `parent` - the parent `Composite` of the `java.awt.Frame`
Returns:
  a `java.awt.Frame` the embedded frame or `null`.
Throws:
  `IllegalArgumentException` -
  - ERROR_NULL_ARGUMENT - if the parent is null
Since:
  3.2

### new_Frame

public static Frame new_Frame(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: 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` - the parent `Composite` of the new `java.awt.Frame`
Returns:
  a `java.awt.Frame` to be the parent of the embedded AWT components
Throws:
  `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_Shell

public static Shell new_Shell(Display display, 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` - the display for the new Shell
  `parent` - the parent `java.awt.Canvas` of the new Shell
Returns:
  a `Shell` to be the parent of the embedded SWT widgets
Throws:
  `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