Core Java| JSP| Servlets| XML| EJB| JEE5| Web Services| J2ME| Glossary| Questions?

 

 

 

 

 

 

 

 

 

 

 

 

 

Search Tutorials

Latest Questions
Comments
 
JTree Open Icon 
 

In this section, you will learn to open an icon in JTree. That means when you click any node of a tree, icon will be displayed on the frame.

 

JTree Open Icon

                         

In this section, you will learn to open an  icon in JTree. That means when you click any node of a tree, icon will be displayed on the frame. 

Program Description:

The following program displays icons when you click the node of JTree. For this you need an icon  to be displayed on the frame. Program uses the makeIcon() method to create a UIDefaults and an ImageIcon UIResource for the given specified gif file.The LookAndFeel plugins these component   Finally, the UIManager class keeps  the current look and feel of he given image to be showed, if you click any node of the tree. 

UIManager : 
The UIManager class keeps the current look and feel and its defaults which are as follows:.
 

  • If the system property swing.defaultlaf is non-null, the default look and feel is used .
  • If the swing.properties exist and contains the swing.defaultlaf key, it uses its value as the default look and feels class uses its values..Otherwise it uses Java look and feel.

Here is the code of this program:

import javax.swing.*;
import javax.swing.JTree;
import java.awt.BorderLayout;
import java.awt.Container;

public class JTreeOpenIcon {
  public static void main(String args[]) {
    JFrame fm = new JFrame("JTree openIcon frame");
    Object iconObject = LookAndFeel.makeIcon(JTreeOpenIcon.class, "world.gif");
    UIManager.put("Tree.leafIcon", iconObject);
    JTree tree = new JTree();
    JScrollPane scrollPane = new JScrollPane(tree);
    Container contentPane = fm.getContentPane();
    contentPane.add(scrollPane, BorderLayout.CENTER);
    fm.setSize(300300);
    fm.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    fm.setVisible(true);
  }
}

Download this program.

Output this program:

                         

» View all related tutorials
Related Tags: c ide class methods method get icon height vi width change using int id ai create js define show paint

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 
Training Courses
Tell A Friend
Your Friend Name
Software Solutions
Least Viewed
Most Rated
Recently Viewed
Search Tutorials

 

 
 

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 | Flex 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.