I am developing a plugin in Eclipse, that shows the results in a scrolledComposite. The composite contains a JFace TreeViewer. I want to print this TreeViewer to the printer. I found import org.eclipse.swt.printing.Printer; to print to the printer.
But when i am printing using following snippet
GC gc= new GC(printer); Control abc[] = Composite.getChildren(); abc[0].print(gc);
The tree that i want to print contains the workspace, project explorer. The print output is showing only the icons. it is not displaying the names of classes, methods.
i can开发者_开发问答t post screenshot till my reputation is above 10.check it here
Please let me know if i am not clear..
Thanks in advance
Ramesh Emandi
Tree myWidget = treeViewer.getTree();
Point size = myWidget.getSize();
Image image = new Image(display, size.x, size.y);
GC gc = new GC(myWidget);
gc.copyArea(image, 0, 0);
gc.dispose();
// Get the ImageData and create a new printer Image from it
ImageData imageData = image.getImageData();
Image printImage = new Image(printer, imageData);
http://www.eclipse.org/swt/faq.php#noprintimage
精彩评论