Menu

Printing a Tree

2008-05-16
2013-04-10
  • Nobody/Anonymous

    Hello,
    Snippet1.java shows how to print a Table-widget. Does anybody know how to print a SWT-Tree-widget?

    thanx

     
    • Matthew Hall

      Matthew Hall - 2008-05-16

      This should work for trees with no TreeColumns.  If you use tree columns you will have to find a way to make a hybrid of this and Snippet1:

      Print createPrint(Tree tree) {
        GridPrint grid = new GridPrint("d", new DefaultGridLook(5, 2));
        for (int i = 0; i < tree.getItemCount(); i++) {
          grid.add(createPrint(tree.getItem(i)));
        }
        return grid;
      }

      Print createPrint(TreeItem item) {
        GridPrint grid = new GridPrint("16dlu, d", new DefaultGridLook(5, 2));
        grid.add(new new TextPrint(item.getText()), 2);
        for (int i = 0; i < item.getItemCount(); i++) {
          grid.add(new EmptyPrint());
          grid.add(createPrint(item.getItem(i)));
        }
        return grid;
      }

      Matthew

       

Log in to post a comment.

MongoDB Logo MongoDB