Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-07-2008, 04:54 PM
Java Tip's Avatar
Moderator
 
Join Date: Nov 2007
Posts: 1,691
Rep Power: 5
Java Tip will become famous soon enoughJava Tip will become famous soon enough
Default How to create a SWT Tree
Code:
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeItem;

/**
 * @author Steven Holzner
 * 
 * To change the template for this generated type comment go to
 * Window>Preferences>Java>Code Generation>Code and Comments
 */

public class SWTTrees {

  public static void main(String[] args) {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Trees");

    final Tree tree = new Tree(shell, SWT.BORDER);
    tree.setSize(290, 290);
    shell.setSize(300, 300);

    for (int loopIndex1 = 0; loopIndex1 < 5; loopIndex1++) {
      TreeItem item0 = new TreeItem(tree, 0);
      item0.setText("Level 0 Item " + loopIndex1);
      for (int loopIndex2 = 0; loopIndex2 < 5; loopIndex2++) {
        TreeItem item1 = new TreeItem(item0, 0);
        item1.setText("Level 1 Item " + loopIndex2);
        for (int loopIndex3 = 0; loopIndex3 < 5; loopIndex3++) {
          TreeItem item2 = new TreeItem(item1, 0);
          item2.setText("Level 2 Item " + loopIndex3);
        }
      }
    }

    shell.open();
    while (!shell.isDisposed()) {      if (!display.readAndDispatch())
        display.sleep();
    }
    display.dispose();
  }
}
__________________
"The sole cause of man’s unhappiness is that he does not know how to stay quietly in his room." - Blaise Pascal
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create a SWT Tree with multi columns Java Tip SWT 0 07-07-2008 04:50 PM
tree sort bigdoggy New To Java 5 05-01-2008 05:52 AM
Need Help With Tree Adt avi New To Java 0 03-20-2008 03:11 AM
Creating a tree Preethi AWT / Swing 0 01-07-2008 01:04 PM
create a tree when a new class is created osval Advanced Java 1 08-06-2007 08:58 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 08:00 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org