如题!

解决方案 »

  1.   

    import org.eclipse.swt.layout.GridLayout;
    import org.eclipse.swt.graphics.Point;
    import org.eclipse.swt.widgets.Shell;
    import org.eclipse.swt.widgets.Tree;
    import org.eclipse.swt.widgets.TreeItem;
    import org.eclipse.swt.SWT;
    import org.eclipse.swt.graphics.Rectangle;public class Tree_yyc {    private Shell sShell = null;
        private Tree tree = null;    /**
         * This method initializes sShell
         */
        private void createSShell() {
            sShell = new Shell();
            sShell.setText("Shell");
            sShell.setSize(new Point(300, 200));
            sShell.setLayout(null);
            tree = new Tree(sShell, SWT.NONE);
            tree.setBounds(new Rectangle(2, 3, 81, 165));
            for(int loopIndex1 = 2000; loopIndex1 <= 2008; loopIndex1++) {            TreeItem item0 = new TreeItem(tree, 0);            item0.setText("Year " + loopIndex1);            for(int loopIndex2 = 1; loopIndex2 <= 12; loopIndex2++) {            TreeItem item1 = new TreeItem(item0, 0);            item1.setText("Month " + loopIndex2);
                }            }
        }
    }