Results 1 to 2 of 2
  1. #1
    Java Example is offline Moderator
    Join Date
    Sep 2014
    Posts
    27
    Rep Power
    0

    Default How to create Tree structure using GWT?

    In this tutorial, we will illustrate how to create a Tree Structure using GWT. The steps involved in Building the Tree Structure are described below:-

    final Label label = new Label("Click the Node to view Tree structure")
    Here we are declaring label. Label is a widget that contains text.

    Tree Item root = new TreeItem("Vowels")
    Creating tree item i.e. creating root for tree.TreeItem is a class. In this an item can be contained within a tree.

    root.addItem("a")
    This is the method for adding an item to the root of the tree. Here we are adding a to the tree name "root".

    Tree t = new Tree()

    Tree is a class and it contains a hierarchy of tree items that user can open and close.

    Java Code: Code to create Tree Structure using GWT
    package org.TreeStructure.client;
    
    import com.google.gwt.core.client.EntryPoint;
    import com.google.gwt.user.client.ui.Label;
    import com.google.gwt.user.client.ui.RootPanel;
    import com.google.gwt.user.client.ui.TreeItem;
    import com.google.gwt.user.client.ui.Tree;
    
    public class Treeexample implements EntryPoint {
    
        final Label label = new Label("Click the Node to view Tree structure");
    
        public void onModuleLoad() {
            TreeItem root = new TreeItem("Vowels");
            root.addItem("a");
            root.addItem("e");
            root.addItem("i");
            root.addItem("o");
            root.addItem("u");
            TreeItem root1 = new TreeItem("Digits");
            root1.addItem("1");
            root1.addItem("2");
            root1.addItem("3");
            root1.addItem("4");
            root1.addItem("5");
    
            TreeItem item = new TreeItem();
            root.addItem(item);
            root1.addItem(item);
            Tree t = new Tree();
            t.addItem(root);
            t.addItem(root1);
            RootPanel.get().add(label);
            RootPanel.get().add(t);
        }
    }
    
    Main
    
    .gwt.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <module>
      <inherits name="com.google.gwt.user.User"/>
      <entry-point class  
    
    ="org.TreeStructure.client.Treeexample"/>
      
    </module>
    Output of the program

    How to create Tree structure using GWT?-tree-structure.jpg

  2. #2
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    12,059
    Rep Power
    25

    Default Re: How to create Tree structure using GWT?

    Moved from Java EE -> GWT. Please take the trouble to find and post in the correct section.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

Similar Threads

  1. Tree structure
    By toofast in forum Advanced Java
    Replies: 3
    Last Post: 06-14-2012, 04:25 PM
  2. How to create a tree structure
    By deemu in forum New To Java
    Replies: 7
    Last Post: 03-07-2012, 03:50 PM
  3. Tree Structure
    By chiku in forum New To Java
    Replies: 2
    Last Post: 01-27-2011, 08:31 PM
  4. Problem--How to create dynamic tree structure in jsp using javascript
    By natu in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 08-11-2010, 08:11 AM
  5. Tree structure using JAVA
    By trill in forum Advanced Java
    Replies: 2
    Last Post: 05-27-2010, 11:02 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •