diff options
Diffstat (limited to 'examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java')
-rw-r--r-- | examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java | 70 |
1 files changed, 0 insertions, 70 deletions
diff --git a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java b/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java deleted file mode 100644 index 0436d6cce1..0000000000 --- a/examples/org.eclipse.swt.snippets/src/org/eclipse/swt/snippets/Snippet292.java +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 2008 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * IBM Corporation - initial API and implementation - *******************************************************************************/ -package org.eclipse.swt.snippets; - -/* - * Take a snapshot of a control - * - * For a list of all SWT example snippets see - * http://www.eclipse.org/swt/snippets/ - */ -import org.eclipse.swt.*; -import org.eclipse.swt.graphics.*; -import org.eclipse.swt.widgets.*; -import org.eclipse.swt.layout.*; - -public class Snippet292 { - public static void main(String[] args) { - final Display display = new Display(); - Shell shell = new Shell(display); - final Tree tree = new Tree(shell, SWT.BORDER); - for (int i = 0; i < 5; i++) { - TreeItem treeItem = new TreeItem (tree, SWT.NULL); - treeItem.setText ("TreeItem " + i); - for (int j = 0; j < 3; j++) { - TreeItem subItem = new TreeItem(treeItem, SWT.NONE); - subItem.setText("SubItem " + i + "-" + j); - } - if (i % 3 == 0) treeItem.setExpanded (true); - } - final Label label = new Label (shell, SWT.NONE); - label.addListener (SWT.Dispose, new Listener () { - public void handleEvent (Event e) { - Image image = label.getImage (); - if (image != null) image.dispose (); - } - }); - Button button = new Button (shell, SWT.PUSH); - button.setText ("Snapshot"); - button.addListener (SWT.Selection, new Listener () { - public void handleEvent (Event e) { - Image image = label.getImage (); - if (image != null) image.dispose (); - image = new Image (display, tree.getBounds ()); - GC gc = new GC (image); - tree.print (gc); - gc.dispose (); - label.setImage (image); - } - }); - GridLayout layout = new GridLayout (2, true); - shell.setLayout(layout); - tree.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); - label.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true)); - button.setLayoutData (new GridData (SWT.FILL, SWT.FILL, true, true, 2, 1)); - shell.pack(); - shell.open(); - while (!shell.isDisposed()) { - if (!display.readAndDispatch()) display.sleep(); - } - display.dispose(); - } -}
\ No newline at end of file |