Home | Ajax | BioInformatics | Dojo | EAI | EJB | Hibernate | J2ME | Java | Java Glossary | Java Servlets | JavaScript | Jboss | JDBC | JDO | Jmeter | JSF | JSP | JUnit | Maven | MySQL | Spring Framework | SQL | Struts | Technology | WAP | Web Services | XML


 
  
 
Programming Tutorials: Ajax | Articles | JSP | Bioinformatics | Database | Free Books | Hibernate | J2EE | J2ME | Java | JavaScript | JDBC | JMS | Linux | MS Technology | PHP | RMI | Web-Services | Servlets | Struts | UML
 

 
Facing Programming Problem?
Ask Questions?, Browse Latest Questions, Question-Answer Guidelines
Java
  JDO Tutorials
  EAI Articles
  Struts Tutorials
  Java Tutorials
  Java Certification
  Java Applet
Questions
Comments

Adding Horizontal lines to Group Nodes

                         

Introduction

In this section, you will learn  to create a horizontal tree in java.

Description of the Program:

This program creates a JTree that contains a root and the nodes.This program implements a class (JTreeHorizontal). Here the init() method creates  root and the child nodes through DefaultMutableTreeNode method. These objects are added in the JTree and the putClintProperty() method displays them horizontally in a  JTree on the frame. 

putclientProperty(Object key, Object val):  The clientProperty dictionary is not intended to support large scale extensions to Jcomponent nor should it  be considered an alternative to subclassing when designing a new component. It takes following type values:

        key: This is the client property key.
        val: This is the client property value.

Here is the code of this program:

import javax.swing.*;
import javax.swing.tree.*;
import java.awt.*;

public class JTreeHorizontal extends JFrame{
  JTree tree;
  public JTreeHorizontal(){
    super("JTreeHorizontal Frame");
    setSize(300300);
    setDefaultCloseOperation(EXIT_ON_CLOSE);
  }

  public void init(){
    DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
    DefaultMutableTreeNode book = new DefaultMutableTreeNode("Book");
    DefaultMutableTreeNode javabook = new DefaultMutableTreeNode("Java Book")
    DefaultMutableTreeNode jspbook = new DefaultMutableTreeNode("JSP Book")
    DefaultMutableTreeNode phpbook = new DefaultMutableTreeNode("PHP Book")
    DefaultMutableTreeNode structbook = new DefaultMutableTreeNode("STRUCT Book")
    DefaultMutableTreeNode contry = new DefaultMutableTreeNode("CONTRY");
    DefaultMutableTreeNode india = new DefaultMutableTreeNode("INDIA");
    DefaultMutableTreeNode usa = new DefaultMutableTreeNode("USA");
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    tree = new JTree(treeModel);
    tree.putClientProperty("JTree.lineStyle""Horizontal");
    treeModel.insertNodeInto(book,root, 0);
    treeModel.insertNodeInto(contry,root, 0);
    book.add(javabook);
    book.add(jspbook);
    book.add(phpbook);
    book.add(structbook);
    contry.add(india);
    contry.add(usa);
    getContentPane().add(tree, BorderLayout.CENTER);
  }

  public static void main(String args[]){

    JTreeHorizontal jh = new JTreeHorizontal();
    jh.init();
    jh.setVisible(true);
  }
}

Download this program.

Output this program: 

                         

Leave your comment:

Name:

Email:

URL:

Title:

Comments:


Enter Code:

Audio Version
Reload Image
 

Note: Emails will not be visible or used in any way, and are not required. Please keep comments relevant. Any content deemed inappropriate or offensive may be edited and/or deleted.

No HTML code is allowed. Line breaks will be converted automatically. URLs will be auto-linked. Please use BBCode to format your text.

Add This Tutorial To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Latest Searches:
table model
Why Virtual Dedicated
HttpSessionActivationL
http get example
Uploading Employee Pro
MurachÑ?Ð?Ð?Ñ??Ñ?Ð????
jdbc html jsp
set colours Jtree
buffer
java set methods
examples of sql
connect SQL server in
FCKediter
Initialization
JSF richfaces for tree
converting calender to
Round robin
yield function in thre
getQueryParam
netbeans jsp
how to write hql in da
servlets programming
mysql blob
send multimessages fro
ajax
pthread.h
DOM parsers.
MurachÑ?Ð???Ñ?Ð??Ñ?Ð??
org.gjt.mm.mysql.Drive
jdbc insert
Passing Parameters in
JDBC with Mysql in Ecl
jdbc mysql connection
how to read xml file i
lucene in windows
capturing
html textarea
HTML Images Text Over
json lib/componen...]=
joining queries in SQ
Spring sample
java jtable
pseudocode of magic sq
header
jdk1.6.0_07 download
Write a program to acc
rrrrrrrrrr
input in java
weblogic server 9.2
HWPF
java events
Get Data from Database
login eample code usin
split
h:message
hibernate with logj4 l
example for registrati
axis2
reverse of a number
Contenttype
Photoshop Matrix Motio
two
connection pooling
Summary - Expressions
Jframe Tutorials
example of one dimensi
Get first day of week
print values from tabl
jstl list size
submit
MurachаÑ?°а?аÑ????
Ñ?Ð?Ð???Ñ?Ð?Ð?Ñ?Ð?Ð??Ñ
?ั?ะ?ะ?ั?ะ??
bitsets
get Numeric Value
velocity
upload file in java st
delete ajax php
jsp Insert insert data
createbargraphinjava
Java String toLowerCase Example
Java String toCharArray Example
Java String substring Example
Java String indexOf Example
Java String startsWith Example
Java String hashCode Example
Java String matches Example
Java String length Example
Java String lastIndexOf Example
Java String isEmpty Example
Java String equalsIgnoreCase Example
Java String equals Example
Java String endsWith Example
Java String copyValueOf Example
Java String contentEquals Example
  EAI Articles
  Java Certification
Tell A Friend
Your Friend Name
Search Tutorials

 

 
 
Browse all Java Tutorials
Java JSP Struts Servlets Hibernate XML
Ajax JDBC EJB MySQL JavaScript JSF
Maven2 Tutorial JEE5 Tutorial Java Threading Tutorial Photoshop Tutorials Linux Technology
Technology Revolutions Eclipse Spring Tutorial Bioinformatics Tutorials Tools SQL
 

Home | JSP | EJB | JDBC | Java Servlets | WAP  | Free JSP Hosting  | Search Engine | News Archive | Jboss 3.0 tutorial | Free Linux CD's | Forum | Blogs

About Us | Advertising On RoseIndia.net  | Site Map

India News

Indian Software Development Company | iPhone Development Company in India | Java Training Delhi | Java Training at Noida |

Send your comments, Suggestions or Queries regarding this site at roseindia_net@yahoo.com.

Copyright © 2008. All rights reserved.