*** empty log message ***
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet258.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet258.java
index e91de7c..6f637f6 100644
--- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet258.java
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet258.java
@@ -19,6 +19,7 @@
* @since 3.3
*/
import org.eclipse.swt.*;
+import org.eclipse.swt.graphics.*;
import org.eclipse.swt.widgets.*;
import org.eclipse.swt.layout.*;
import org.eclipse.swt.events.*;
@@ -27,9 +28,22 @@
public static void main(String[] args) {
Display display = new Display();
Shell shell = new Shell(display);
- shell.setLayout(new GridLayout());
+ shell.setLayout(new GridLayout(2, false));
final Text text = new Text(shell, SWT.SEARCH | SWT.CANCEL);
+ Image image = null;
+ if ((text.getStyle() & SWT.CANCEL) == 0) {
+ image = new Image (display, Snippet258.class.getResourceAsStream("cancel.gif"));
+ ToolBar toolBar = new ToolBar (shell, SWT.FLAT);
+ ToolItem item = new ToolItem (toolBar, SWT.PUSH);
+ item.setImage (image);
+ item.addSelectionListener(new SelectionAdapter() {
+ public void widgetSelected(SelectionEvent e) {
+ text.setText("");
+ System.out.println("Search cancelled");
+ }
+ });
+ }
text.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
text.setText("Search text");
text.addSelectionListener(new SelectionAdapter() {
@@ -47,5 +61,7 @@
while (!shell.isDisposed()) {
if (!display.readAndDispatch()) display.sleep();
}
+ if (image != null) image.dispose();
+ display.dispose();
}
}
\ No newline at end of file
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/cancel.gif b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/cancel.gif
new file mode 100644
index 0000000..6f64766
--- /dev/null
+++ b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/cancel.gif
Binary files differ