# Class WidgetSpy

java.lang.Object
org.eclipse.swt.internal.WidgetSpy

public class WidgetSpy extends Object
Helper class to allow widget creation and disposal monitoring

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`WidgetSpy.NonDisposedWidgetTracker`
Default implementation simply collects all created and not disposed widgets
`static interface`
`WidgetSpy.WidgetTracker`
Custom callback to register widget creation / disposal

## Field Summary

Fields
Modifier and Type
Field
Description
`static boolean`
`isEnabled`
Flag to prevent `Widget` from entering this class during debugging, if tracking of creation and disposal is not enabled.

## Method Summary

Modifier and Type
Method
Description
`static WidgetSpy`
`getInstance()`
`void`
`setWidgetTracker(WidgetSpy.WidgetTracker tracker)`
Enables tracking of `Widget` object creation and disposal.
`void`
`widgetCreated(Widget widget)`
`void`
`widgetDisposed(Widget widget)`

### Methods inherited from class Object

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

## Field Details

### isEnabled

public static boolean isEnabled
Flag to prevent `Widget` from entering this class during debugging, if tracking of creation and disposal is not enabled.

## Method Details

### getInstance

public static WidgetSpy getInstance()

### setWidgetTracker

public void setWidgetTracker(WidgetSpy.WidgetTracker tracker)
Enables tracking of `Widget` object creation and disposal. WARNING: the tracker will be called from the UI thread. Do not block it and do not throw any exceptions.

Parameters:
  `tracker` - notified when a widget is created or disposed. Use `null` to disable tracking. The tracker will be notified of widgets created and disposed after setting the tracker.

### widgetCreated

public void widgetCreated(Widget widget)

### widgetDisposed

public void widgetDisposed(Widget widget)