- + sign in a jtree

hi,
do we can replace the - + sign at the left of a jtree node by an icon ?
if yes, how ?.
thanks a lot

Before putting any components on the screen,
set some 'user' UI options:
UIManager.put("Tree.expandedIcon", expandedIcon);
UIManager.put("Tree.collapsedIcon", collapsedIcon);       where expandedIcon and collapsedIcon are your ImageIcons.
For a quick demo...
UIManager.put("Tree.expandedIcon",  UIManager.getIcon("Tree.openIcon"));
UIManager.put("Tree.collapsedIcon",  UIManager.getIcon("Tree.closedIcon"));               

Similar Messages

  • JTree not showing plus/minus signs

    Hi,
    I'm having a strange problem with JTree when implementing my own DefaultTreeCellRenderer: the renderer is shown correctly, but the plus and minus signs are gone!
    My getTreeCellRendererComponent implementation actually creates a new JPanel and returns it instead of the default one. Can that be the problem? How can I make these plus/minus signs come back?
    Thanks, U

    I have seen something a little different on my CustomCellRenderer where the plus minus sign is replaced with some default arrow icon and where it comes from I have no clue. I basically have a 3 level deep tree and its at the B level where this icon appears.
    http://www.matthewscorp.com/images/JTreeError.jpg
    For the life of me I can't figure this one out. I have tried all ideas like set all the renderer icons or the LAF properties icons and still this blue arrow appears. Any ideas would help on both mine and the original poster.

  • How to replace original JTree node with + and - sign or icon??

    Dear friends:
    I have following code for JTree:
    import java.awt.BorderLayout;
    import java.awt.Container;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    public class TreeSample {
      public static void main(String args[]) {
        JFrame f = new JFrame("JTree Sample");
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        Container content = f.getContentPane();
        JTree tree = new JTree();
        JScrollPane scrollPane = new JScrollPane(tree);
        content.add(scrollPane, BorderLayout.CENTER);
        f.setSize(300, 200);
        f.setVisible(true);
    }Here, when I click any node to explore its children, right handle pointer become down handle Pointer, but if I hope to change this right handle pointer to + sign or icon; and to change this down handle pointer to - sign or icon; how to do it, ??
    Is there any simplest way instead of using ImageIcon ????
    Thanks
    sunny

    You have to use Windows look and feel instead of Java look and feel.
    http://java.sun.com/docs/books/tutorial/uiswing/components/tree.html#display

  • Prevent losing + sign on JTree

    I have a jtree which is created on 'As needed' basis. i.e, when the user expands the particular node, I make a database call in TreeWillExpandListener and add the children to their parent.
    Say, the user has clciked on the + sign besides the node and at that point of time the database is down and I get an exception. when I get the exception, the jtree assumes that there are no children and removes the +. Is it possible to prevent '+' being removed when I get exception from backend?
    It would be great if someone has a quick fix for this cos I need this problem to be fixed fast.
    Thanks a loot

    I haven't tried but how is this:DefaultTreeModel model = (DefaultTreeModel) yourTree.getModel();
    model.setAsksAllowsChildren(true);

  • Show + image instead of handle in jtree

    I have created jtree. I have implemented my own TreeCellRendererComponent. I set the node images as per node type. My problem is, I need to get '+' sign to nodes not expanded and '-' for those expanded instead of default handles. How do I implement it?
    public Component getTreeCellRendererComponent(
                        JTree tree, Object value, boolean isSelected,
                        boolean isExpanded, boolean isLeaf, int row,
                        boolean hasFocus) {
              super.getTreeCellRendererComponent( tree, value, isSelected,
                                  isExpanded, isLeaf, row, hasFocus);
              Component compObject = this;
              if ( value instanceof EuamDefaultMutableTreeNode ) {
                   EuamDefaultMutableTreeNode node = (EuamDefaultMutableTreeNode)value;
                   setText( node.getText() );
                   setIcon(isExpanded ? node.getOpenIcon() : node.getClosedIcon() );
                   if( bIsRightImage_ && lblRightSideIcon_ != null ) {
                        lblRightSideIcon_.setIcon(node.getRightIcon());
              else {
                   setText(value.toString());
              return compObject;
    }

    Tree node handles vary depending on which L&F u r using, java defaults to "javax.swing.plaf.metal.MetalLookAndFeel" which uses the "0-" type handles. To get the '+', '-' handles you need to be using windows L&F. Try adding this code to your apps main method:
    try{
       UIManager.setLookAndFeel(
            "com.sun.java.swing.plaf.windows.WindowsLookAndFeel");
    }catch (Exception e) {}Hope this helps

  • JTree move operation

    I have a piece of code which is doing a drag and drop on a JTRee.This code also needs to handle move and copy operations.THe move method does not work the way expected.When I do a drag operation the node gets dragged but is not removed from the parent although pls note that when all the node are removed under a parent and I click on the parent node the plus sign next to the parent disappears and also the nodes disappear. I am not sure what the problem is ..has anyone ever faced such a situation.
    If anybody had any idea as to how to get a move operation on a JTree then your guidance for the same will be highly appreciated.
    Thanks for your help

    Thanks for the reply.I am removing the node from the model.
    I am doing the drag and drop between 2 trees and that is when I have the above mentioned problem.
    But when I drag within the same tree everything works fine.
    Let me explain one thing here that I am using 2 different instance of the same class for the 2 trees is it something like only one of the tree is getting refrehsed and other one is not.If so then how do I ensure that both instance of the tree gets refreshed.Any clues ????

  • Read binary files that are wraped in the downloaded executable signed jar

    Hello, there:
    I have created a Swing application and created a signed jar file and uploaded it to my site. The signed jar includes class packages, and a folder of binary files which are the datasource for my application.
    jws downloads this signed executable jar, it'll automatically run it, but it has problems reading the binary folders wrapped in itself (the app is supposed to read the folder's structure and use the info to create a JTree object, and read the file's content as well). Is it the file path conversion problem? Do we need to use URL instead? I tried it after reading some threads on this forum but didn't make it.
    As an alternatives, I want JWS to unjar the jar file and expand it to exploded files. I manually unjar it and run the app from command line, it works fine.
    Plus, the app is supposed to manipulate the binary files when it's in process, like saving new content back to the files, zip the files and upload them to the remote sql server. therefore, I think it's easy to have it run when it's expanded.
    So here is the question: JWS by default is running the executable jar, is there a way to tell JWS to unzip the jar and find the main class in the exploded files and run it?
    Thanks a lot for your suggestions,
    Sway

    You can get to any resource in a jar file in your classpath. The code below will return InputStream for resource.bin nested two packages down.
    InputStream in = YourClass.class.getResourceAsStream("/com/mypackage/resouce.bin");  //use '/' instead of '.'You can open a FileOutputStream to write that file.
    OutputStream out = new FileOutputStream("myTempResource.bin");
    IOUtil.streamAndClose(in,out);If the resouce is a nested zip or nested jar then you can use the Java Zip utilities to unwrap the stream.

  • Is it possible to display a JTree in a JSP or Servlet

    Hi everyone,
    I was wondering is it possible to display a JTree or something similar into a JSP page or servlet and have it rendered in a webpage?

    no. this is a job for some cunning use of javascript, and images to represent the folders in open/closed state, the lines joining them and the plus/minus signs. it's an absolute pain in the arse to implement, but there are plenty of tutorials on t'internet about it. I'm fairly sure there are ready-to-use libraries for it, too, and if I recall, some kind people have even knocked together some tag libraries for it

  • Expand jTree

    Hi,
    I have got question how to expand JTree. I am using netbeans IDE.
    I would like to save information about last visited position in tree and when I open this window again to expand it to last visited node(leaf).
    I have done someting like that:
    String hostName = getHostName();
    DefaultMutableTreeNode root = new DefaultMutableTreeNode(hostName)
    DefaultTreeModel treeModel = new DefaultTreeModel(root);
    JTree jTree1 = new JTree();
    jTree1.setModel(treeModel);
    //I have create method to create jTree:
    public void setTree(TreePath path)
    DefaultMutableTreeNode newNode;
    //Here I call method to get all root folders. For root it will be all disks.
    File[] folderList = getFolders(...)
    for(File f: folderList)
    newNode = new DefaultMutableTreeNode(f);
    root.add(newNode);
    Ok. That's how it create jTree. This part of code works correct. I invoke this window with other (main) window. I have got treeNode e.g.
    [ TRAVEL, C:\, C:\Program Files ]
    I strange because I checked that on second level node has leaf but it doesn't handle and folder icon. I have tried jTree1.repaint but it doesn't work.
    How can I expand tree to this node. I have been trying:
    --scrollPathToVisible method
    When I select a node by mouse clicking then tree refreshes and show handle with folder icon and all leafs. I have selected the same node using setSelectionPath(treePath) but it is not working and trying to expand it but it is not working.
    Give me a sign if you need more information.
    Peter D.

    It only took me 20 seconds to do a search and find this, but since you've waited over five hours, here's one result I found
    http://forum.java.sun.com/thread.jsp?forum=31&thread=257313

  • JTree - renderer

    When i expand a jtree node, i am populating the content in runtime. I use model.insertNodeInto() method to insert the nodes. I have a dummy node in the first position so that i can get a +, so that i can expand the jtree node. I am changing the first dummy node to a node i want using model.valueForPathChanged() method. Everything works fine. I have a renderer attached. model.insertNodeInto() calls the getTreeCellRendererComponent() method successfully. But model.valueForPathChanged() is not calling the getTreeCellRendererComponent() by default.
    My questions are:
    1. Can i call the renderer forcefully for valueForPathChanged? If so, how?
    2. Is there a easy way to get + for a node, even though the node has no child? i.e a leaf should have + , so that i can expand.
    3. I tried deleting the first node, and insert a new node in first position. But removeNodeFromParent is calling model.reload() which is causing collapse of my node.

    Best thing to do is implementing your own tree mobel
    or tree node.
    It has a method that should retun the number of
    childs a node has. When it return a value greater
    than zero you will get the + sign.I am implementing my own model. but can you help with the exact method to overload and return a value greater than 0. ?
    Thanks.

  • JTree leaf icon

    Hi,
    I am doing a sort of explorer, with a JTree.
    I know how to change icons for leafs, but sometimes my leafs are indeed branches but without nothing in it (an empty directory).
    so the tree displays it as a leaf. But I would like that the tree displays it with the directory icon (but without the "+" sign).
    How can i do this ?
    Sylvain.

    I haven't such problems...
    Ok. You have to create your custom TreeCellRenderer and set it to the tree.
    IconRenderer myRenderer=new IconRenderer ();
    tree.setCellRenderer(myRenderer);
    class IconRenderer extends JLabel implements TreeCellRenderer
    public Component getTreeCellRendererComponent(JTree tree,
              Object value, boolean sel, boolean expanded, boolean leaf,
              int row, boolean hasFocus)
    setText(value.toString());
    //process value (value represents you tree node content)
    if (!leaf) {
    if (expanded)
    setIcon(new ImageIcon("images/expanded.gif"));
    else
    setIcon(new ImageIcon("images/collapsed.gif"));
    else {
    setIcon(new ImageIcon("images/text.gif"));
    MyObject myObj=(MyObject)value;
    if (myObj.isBranch()) {
    setIcon(new ImageIcon("images/branch.gif"));
    regards
    Stas

  • Hashtable or Vector to create Jtree ?Data from dtatbase.

    I want build JTree in JApplet .
    The JApplet is connecting to a database .
    As soon as data change ,JTree change.
    1.How can use hashtable or Vector to create Jtree ?
    the Hashtable's Data or Vector's Data from Database.
    2.How Japplet connect to a database and get data?

    1-How can use hashtable or Vector to create Jtree ?
    read JTree constrcutors in which u can use Vector for creating JTree like new JTree(myVector);
    and in this myVector u can store your own objects and override toString() method of that object (stored in Vector), but as my practice its not good.
    2.How Japplet connect to a database and get data?
    You have to make signed applet for connecting your applet with database , and sorry to say but ita a real pain in your -------------

  • Problem updating JTree via RMI

    I'm programming an Instant Messenger application in Java using RMI extensively. Much like most IM applications, my IM clients display a "buddy list" window upon successful authentication with the server. I have reached a huge stumbling block at this point. My Buddylist JFrame contains a JTree that is used to display the status of the user's buddies (i.e. online, offline). I am able to populate the JTree without any problems BEFORE the JFrame is displayed by using the DefaultTreeModel's insertNodeInto() method. But the problem I'm having is that, once the Buddylist is displayed to the user, I can't successfully update the JTree to reflect changing user status. For example, let's say a user with the screename "qwerty" logs in to the server. Now "qwerty" sees his Buddylist pop up on screen. His Buddylist contains 1 user (for simplicity's sake) with screename "foo". "foo" is currently not logged into the system so "foo" is shown in the Buddylist as a child of node Offline. But right now, let's say that "foo" logs into the system. "qwerty's" Buddylist should be updated to reflect the fact that "foo" just signed in by removing "foo" as a child node of Offline and adding a new node to Online called "foo".
    I currently have this functionality implemented as an RMI callback method on the server side. When "foo" logs in, the server calls the method fireBuddyLoggedOnEvent() with "foo" as the argument. Because "qwerty" is already logged in, and both users are each other's buddy, the statement
         c.getCallback().buddySignedOn(screenname);
    will be executed on the client side. Unfortunately, even though this code is successfully executed remotely, "qwerty's" Buddylist's JTree does not update to show that "foo" is now online. My only suspicion is that this is due to the fact that the Buddylist is already visible and this somehow affects its ability to be updated (remember that I have no problem populating the tree BEFORE it's visible). However, I've weeded out this possibility by creating a test frame in which its JTree is successfully updated, but in response to an ActionEvent in response to a button click. Of course, this test case was not an RMI application and does not come with the complexities of RMI. Please help me resolve this issue as it's preventing me from proceeding with my project.
    ~BTW, sorry for the poor code formatting. I added all the code in wordpad and pasted it in here, which stripped the formatting.
    * Frame that allows the user to enter information to
    * be used to login to the server.
    public class LoginFrame extends JFrame {
         signonButton.addActionListener(new java.awt.event.ActionListener() {
              public void actionPerformed(java.awt.event.ActionEvent e) {
                   if (!screenameTextField.getText().equals("") &&
                   !passwordTextField.getPassword().equals("")) {
                        try {
                             serverInter = (ServerInter) Naming.lookup(serverName);
                             String username = screenameTextField.getText();
                             String password = String.valueOf(passwordTextField.getPassword());
                             int connectionID = serverInter.connect(username, password);
                             System.out.println("authenticate successful");
                             dispose();
                             Buddylist buddyList = new Buddylist(username, connectionID);
                             // Registers the buddylist with the server so that
                             // the server can remotely call methods on the
                             // Buddylist.
                             serverInter.registerCallback(buddyList, connectionID);
                             return;
                             } catch (Exception e1) {
                                  JOptionPane.showMessageDialog(LoginFrame.this, e1.getMessage(),
                                            "Connection Error", JOptionPane.ERROR_MESSAGE);
                                  passwordTextField.setText("");
                                  signonButton.setEnabled(false);
                                  e1.printStackTrace();
         public static void main(String[] args) {
              new LoginFrame();
    public class Buddylist extends JFrame implements BuddylistInter {
         public Buddylist(String username, int connectionID) {
              try {
                   serverInter = (ServerInter) Naming.lookup(serverName);
                   this.username = username;
                   this.connectionID = connectionID;
                   this.setTitle(username + "'s BuddyList");
                   initialize();
                   } catch (Exception e) {
                        e.printStackTrace();
         * Method of interest. Note that this method uses a DynamicTree
         * object as included in the Sun tutorial on JTree's
         * (located at http://www.iam.ubc.ca/guides/javatut99/uiswing/components/tree.html#dynamic).
         * Don't worry too much about where the node is getting added
         * but rather, that i wish to verify that an arbitrary node
         * can successfully be inserted into the tree during this
         * remote method call
         public void buddySignedOn(String screenname) throws RemoteException {
              // should add screename at some location in the tree
              // but doesn't!
              treePanel.addObject(screename);
    * Oversimplified interface for the Buddylist that is intended
    * to be used to allow callbacks to the clientside.
    public interface BuddylistInter extends Remote {
         public void buddySignedOn(String screenname) throws RemoteException;
    * Another oversimplified interface that is to be
    * implemented by the server so that the client can
    * call remote server methods.
    public interface ServerInter extends java.rmi.Remote {
         // "Registers" the given Buddylist with this server to allow
         // remote callbacks on the Buddylist.
         public void registerCallback(Buddylist buddylist, int connectionID)
                             throws RemoteException;
    public class Server extends UnicastRemoteObject implements ServerInter {
         private Vector loggedInUsers = new Vector();
         // Note that this method assumes that a Connection object
         // representing the Buddylist with connectionID was added
         // to the loggedInUsers list during authentication.
         public void registerCallback(Buddylist buddylist, int connectionID) throws RemoteException {          
              int index = loggedInUsers.indexOf(new Connection(connectionID));
              Connection c = (Connection) loggedInUsers.get(index);
              c.setCallback(buddylist);
         // Method that's called whenever a client successfully
         // connects to this server object.
         // screename is the name of the user that successfully
         // logged in.
         private void fireBuddyLoggedOnEvent(String screenname) {
              // Examines each logged in client to determine whether
              // or not that client should be notified of screename's
              // newly logged in status.
              for (int i = 0; i < loggedInUsers.size(); i++) {
                   Connection c = (Connection) loggedInUsers.get(i);
                   if (database1.areBuddies(screenname, c.getUsername())) {
                        try {
                             // getCallback() returns a reference to
                             // the Buddylist that was registered
                             // with this server. At this point,
                             // the server attempts to notify the
                             // client that one of his "buddies" has
                             // just logged into the server.
                             c.getCallback().buddySignedOn(screenname);
                        } catch (RemoteException e) {
                             e.printStackTrace();
    }

    Ok, I deleted all .class files, recomplied, and rmic'd, and I still get the IllegalArgumentException. So I've decided to just post all the code here because I don't want to make an assumption that all the code is correct. Thanks for helping me out with this very stressful problem.
    * Created on Nov 13, 2006
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.IOException;
    import java.net.MalformedURLException;
    import java.rmi.Naming;
    import java.rmi.NotBoundException;
    import java.rmi.RemoteException;
    import java.rmi.server.UnicastRemoteObject;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JPanel;
    import javax.swing.JSeparator;
    import javax.swing.SwingUtilities;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class Buddylist extends JFrame implements BuddylistInter {
         private String serverName = "//Broom:" + "5001" + "/IMServer";
         private DynamicTree treePanel = null;
         private String onlineString = "Online";
         private String offlineString = "Offline";
         private DefaultMutableTreeNode onlineNode = null;
         private DefaultMutableTreeNode offlineNode = null;
         private ImageUpdater imageUpdater = null;
         private javax.swing.JPanel jContentPane = null;
         private ServerInter serverInter = null;
         private String username = null;
         // A connectionID of -1 indicates that this Buddylist
         // has not yet received a valid id from the server.
         private int connectionID = -1;
         private JMenuBar jJMenuBar = null;
         private JMenu jMenu = null;
         private JMenu jMenu1 = null;
         private JMenu jMenu2 = null;
         private JPanel imagePanel = null;
         private JSeparator jSeparator1 = null;
         public Buddylist(String username, int connectionID) {
             try {
                   serverInter = (ServerInter) Naming.lookup(serverName);
                   this.username = username;
                   this.connectionID = connectionID;
                   this.setTitle(username + "'s BuddyList");
                   imageUpdater = new ImageChooser(this);
                   initialize();
                    * This statement is causing an IllegalArgumentException
                    * to be thrown! I've tried inserting it at the beginning
                    * of the constructor and that doesn't help.
                   UnicastRemoteObject.exportObject(this);
              } catch (MalformedURLException e) {
                   e.printStackTrace();
              } catch (RemoteException e) {
                   e.printStackTrace();
              } catch (NotBoundException e) {
                   e.printStackTrace();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setJMenuBar(getJJMenuBar());
              this.setPreferredSize(new java.awt.Dimension(196,466));
              this.setMinimumSize(new java.awt.Dimension(150,439));
              this.setSize(196, 466);
              this.setContentPane(getJContentPane());
              this.setLocationRelativeTo(null);
              this.setVisible(true);
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private javax.swing.JPanel getJContentPane() {
              if(jContentPane == null) {
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(null);
                   jContentPane.add(getImagePanel(), null);
                   jContentPane.add(getJSeparator1(), null);
                   jContentPane.add(getTreePanel(), null);
              return jContentPane;
         private DynamicTree getTreePanel() {
              if (treePanel == null) {
                   treePanel = new DynamicTree();
                   onlineNode = treePanel.addObject(null, onlineString);
                   offlineNode = treePanel.addObject(null, offlineString);
                   treePanel.setBounds(6, 138, 177, 196);
                   populateTree();
                   return treePanel;
              return null;
         private void populateTree() {
              try {
                   String [] buddies = serverInter.getBuddyList(this.username);
                   for (int i = 0; i < buddies.length; i++) {
                        try {
                             if (serverInter.isBuddyOnline(buddies)) {
                                  treePanel.addObject(onlineNode, buddies[i]);
                             else {
                                  treePanel.addObject(offlineNode, buddies[i]);
                        } catch (RemoteException e1) {
                             e1.printStackTrace();
              } catch (RemoteException e) {
                   e.printStackTrace();
         * This method initializes jJMenuBar     
         * @return javax.swing.JMenuBar     
         private JMenuBar getJJMenuBar() {
              if (jJMenuBar == null) {
                   jJMenuBar = new JMenuBar();
                   jJMenuBar.add(getJMenu());
                   jJMenuBar.add(getJMenu1());
                   jJMenuBar.add(getJMenu2());
              return jJMenuBar;
         * This method initializes jMenu     
         * @return javax.swing.JMenu     
         private JMenu getJMenu() {
              if (jMenu == null) {
                   jMenu = new JMenu();
                   jMenu.setText("My IM");
              return jMenu;
         * This method initializes jMenu1     
         * @return javax.swing.JMenu     
         private JMenu getJMenu1() {
              if (jMenu1 == null) {
                   jMenu1 = new JMenu();
                   jMenu1.setText("People");
              return jMenu1;
         * This method initializes jMenu2     
         * @return javax.swing.JMenu     
         private JMenu getJMenu2() {
              if (jMenu2 == null) {
                   jMenu2 = new JMenu();
                   jMenu2.setText("Help");
              return jMenu2;
         * This method initializes imagePanel     
         * @return javax.swing.JPanel     
         private JPanel getImagePanel() {
              if (imagePanel == null) {
                   imagePanel = new JPanel();
                   imagePanel.setBounds(6, 2, 176, 125);
                   try {
                        BufferedImage bi =
                             ImageIO.read(
                                       getClass().getClassLoader().getResourceAsStream("images/cute_dog.jpg"));
                        Image scaled = bi.getScaledInstance(
                                  imagePanel.getWidth(), imagePanel.getHeight(), BufferedImage.SCALE_FAST);
                        final JLabel imageLabel = new JLabel(new ImageIcon(scaled));
                        imageLabel.setToolTipText("Double click to change image");
                        imagePanel.add(imageLabel, imageLabel.getName());
                        imageLabel.addMouseListener(new java.awt.event.MouseAdapter() {
                             public void mouseClicked(java.awt.event.MouseEvent e) {
                                  if (e.getClickCount() == 2) {
                                       Image selected = imageUpdater.getSelectedImage();
                                       if (selected != null) {
                                            BufferedImage bi = (BufferedImage) selected;
                                            Image scaled = bi.getScaledInstance(
                                                      imageLabel.getWidth(), imageLabel.getHeight(), BufferedImage.SCALE_DEFAULT);
                                            imageLabel.setIcon(new ImageIcon(scaled));
                   } catch (IOException e) {
                        e.printStackTrace();
              return imagePanel;
         * This method initializes jSeparator1     
         * @return javax.swing.JSeparator     
         private JSeparator getJSeparator1() {
              if (jSeparator1 == null) {
                   jSeparator1 = new JSeparator();
                   jSeparator1.setBounds(6, 132, 176, 1);
              return jSeparator1;
         public void buddySignedOn(String screenname) throws RemoteException {
              final String temp = screenname;
              Runnable addBuddy = new Runnable() {
                   public void run() {
                        treePanel.addObject(onlineNode, temp);
              SwingUtilities.invokeLater(addBuddy);
         public void buddySignedOff(String screenname) throws RemoteException {
              // TODO Auto-generated method stub
         public boolean equals(Object o) {
              Buddylist buddylist = (Buddylist) o;
              return connectionID == buddylist.connectionID;
         public int hashCode() {
              return connectionID;
    } // @jve:decl-index=0:visual-constraint="10,11"
    * Created on Nov 4, 2006
    import java.rmi.Remote;
    import java.rmi.RemoteException;
    public interface BuddylistInter extends Remote {
         public void buddySignedOn(String screenname) throws RemoteException;
         public void buddySignedOff(String screenname) throws RemoteException;
    * Created on Oct 14, 2006
    * Models a single endpoint of a connection between machines.
    * @author Josh Feldman
    public class Connection {
         private String username;
         private final int connectionID;
         private Buddylist callback = null;
         public Connection(String username, int connectionID) {
              this.username = username;
              this.connectionID = connectionID;
         public Connection(int connectionID) {
              this.connectionID = connectionID;
         public String getUsername() {
              return username;
         public int getConnectionID() {
              return connectionID;
         public void setCallback(Buddylist buddylist) {
              this.callback = buddylist;
         public Buddylist getCallback() {
              return callback;
         public boolean equals(Object o) {     
              Connection otherConnection = (Connection) o;
              if (otherConnection.getConnectionID() == this.connectionID) {
                   return true;
              else {
                   return false;
         public int hashCode() {
              return connectionID;
    * Created on Nov 4, 2006
    import java.io.File;
    import java.io.FileInputStream;
    import java.io.IOException;
    import java.io.Serializable;
    import java.util.Properties;
    public class Database implements Serializable{
         private final String regex = ";";
         private Properties db = null;
         private String dbPath = "buddies.txt";
         public Database() throws IOException {
              db = new Properties();
              File buddiesFile = new File(dbPath);
              if (!buddiesFile.canRead()) {
                   throw new IOException("Can't read database!");
              try {
                   FileInputStream fis = new FileInputStream(buddiesFile);
                   db.load(fis);
                   System.out.println("database loaded from file");
              } catch (IOException e) {
                   e.printStackTrace();
                   System.err.println("Can't load the database! Exiting program...");
                   System.exit(0);
          * called when a user adds/deletes a user from the buddylist
         public void changeBuddyList() {
              //TODO
         public boolean doesUserExist(String username) {
              System.out.println(db.getProperty(username));
              return db.getProperty(username) != null;
         public String getPassword(String username) {
              String temp = db.getProperty(username);
              String [] split = temp.split(regex);
              if (split.length == 2)
                   return split[0];
              else {
                   return null;
         public String getBuddies(String username) {
              String temp = db.getProperty(username);
              if (temp == null)
                   return null;
              String [] split = temp.split(regex);
              if (split.length != 2)
                   return null;
              else {
                   return split[1];
          * Determines whether screename1 is a buddy of screename2
          * @return
         public boolean areBuddies(String screename1, String screename2) {
              String [] buddies = getUserBuddies(screename2);
              if (buddies == null) {
                   return false;
              else {
                   for (int i = 0; i < buddies.length; i++) {
                        if (buddies.equals(screename1)) {
                             return true;
              return false;
         public String [] getUserBuddies(String username) {
              System.out.println("in db getUserBuddies: username = " + username);
              String temp = db.getProperty(username);
              if (temp == null)
                   return null;
              String [] split = temp.split(regex);
              if (split.length != 2)
                   return null;
              else {
                   return split[1].split(",");
    import java.awt.GridLayout;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTree;
    import javax.swing.event.TreeModelEvent;
    import javax.swing.event.TreeModelListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.MutableTreeNode;
    import javax.swing.tree.TreePath;
    import javax.swing.tree.TreeSelectionModel;
    // Note that this is not my code but rather code taken
    // from java Sun tutorial
    public class DynamicTree extends JPanel {
        protected DefaultMutableTreeNode rootNode;
        protected DefaultTreeModel treeModel;
        protected JTree tree;
        public DynamicTree() {
            rootNode = new DefaultMutableTreeNode("Root Node");
            treeModel = new DefaultTreeModel(rootNode);
            treeModel.addTreeModelListener(new MyTreeModelListener());
            tree = new JTree(treeModel);
            tree.setRootVisible(false);
            tree.setEditable(false);
            tree.getSelectionModel().setSelectionMode
                    (TreeSelectionModel.SINGLE_TREE_SELECTION);
            tree.setShowsRootHandles(false);
            JScrollPane scrollPane = new JScrollPane(tree);
            setLayout(new GridLayout(1,0));
            add(scrollPane);
        /** Remove all nodes except the root node. */
        public void clear() {
            rootNode.removeAllChildren();
            treeModel.reload();
        /** Remove the currently selected node. */
        public void removeCurrentNode() {
            TreePath currentSelection = tree.getSelectionPath();
            if (currentSelection != null) {
                DefaultMutableTreeNode currentNode = (DefaultMutableTreeNode)
                             (currentSelection.getLastPathComponent());
                MutableTreeNode parent = (MutableTreeNode)(currentNode.getParent());
                if (parent != null) {
                    treeModel.removeNodeFromParent(currentNode);
                    return;
        public void removeObject(DefaultMutableTreeNode child) {
             treeModel.removeNodeFromParent(child);
    //         treeModel.reload();
        /** Add child to the currently selected node. */
        public DefaultMutableTreeNode addObject(Object child) {
            DefaultMutableTreeNode parentNode = null;
            TreePath parentPath = tree.getSelectionPath();
            if (parentPath == null) {
                parentNode = rootNode;
            } else {
                parentNode = (DefaultMutableTreeNode)
                             (parentPath.getLastPathComponent());
            return addObject(parentNode, child, true);
        public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
                                                Object child) {
            return addObject(parent, child, false);
        public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
                                                Object child,
                                                boolean shouldBeVisible) {
            DefaultMutableTreeNode childNode =
                    new DefaultMutableTreeNode(child);
            if (parent == null) {
                parent = rootNode;
            treeModel.insertNodeInto(childNode, parent,
                                     parent.getChildCount());
            // Make sure the user can see the lovely new node.
            if (shouldBeVisible) {
                tree.scrollPathToVisible(new TreePath(childNode.getPath()));
            return childNode;
        class MyTreeModelListener implements TreeModelListener {
            public void treeNodesChanged(TreeModelEvent e) {
                DefaultMutableTreeNode node;
                node = (DefaultMutableTreeNode)
                         (e.getTreePath().getLastPathComponent());
                 * If the event lists children, then the changed
                 * node is the child of the node we've already
                 * gotten.  Otherwise, the changed node and the
                 * specified node are the same.
                try {
                    int index = e.getChildIndices()[0];
                    node = (DefaultMutableTreeNode)
                           (node.getChildAt(index));
                } catch (NullPointerException exc) {}
                System.out.println("The user has finished editing the node.");
                System.out.println("New value: " + node.getUserObject());
            public void treeNodesInserted(TreeModelEvent e) {
            public void treeNodesRemoved(TreeModelEvent e) {
            public void treeStructureChanged(TreeModelEvent e) {
        public DefaultTreeModel getModel() {
             return treeModel;
    * Created on Sep 24, 2006
    import java.awt.Frame;
    import java.awt.Image;
    import javax.swing.JComponent;
    * Generic Dialog for allowing a user to browse
    * his filesystem for an image file. Dialog
    * displays a preview of the image (if it is in fact
    * displayable).
    * @author Josh Feldman
    public class ImageChooser extends JComponent implements ImageUpdater{
         private Frame parent = null;
         public ImageChooser(Frame parent) {
              super();
              this.parent = parent;
         public Image getSelectedImage() {
              ImageChooserDialog dialog = new ImageChooserDialog(parent);
              if (dialog.showDialog() == ImageChooserDialog.OK_OPTION) {
                   return dialog.getSelectedImage();
              return null;
    }  //  @jve:decl-index=0:visual-constraint="10,10"
    * Created on Sep 24, 2006
    import java.awt.Frame;
    import java.awt.Image;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import javax.imageio.ImageIO;
    import javax.swing.JDialog;
    import javax.swing.ImageIcon;
    import javax.swing.JFileChooser;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.JTextField;
    import javax.swing.JButton;
    * Class that displays a dialog that allows a user
    * to browse his/her filesystem for an image file
    * for selection.
    * @author Josh Feldman
    public class ImageChooserDialog extends JDialog {
         private Frame parent = null;
         private JFileChooser fileChooser = new JFileChooser();
         private int option;
         public final static int OK_OPTION = 1;
         public final static int CANCEL_OPTION = 2;
         private Image selectedImage = null;
         private javax.swing.JPanel jContentPane = null;
         private JPanel previewPanel = null;
         private JLabel jLabel = null;
         private JTextField filenameTextField = null;
         private JButton browseButton = null;
         private JButton cancelButton = null;
         private JButton okButton = null;
         private JLabel previewLabel = null;
          * This is the default constructor
         public ImageChooserDialog(Frame parent) {
              super();
              this.parent = parent;
              this.setTitle("Select Image");
              initialize();
         public ImageChooserDialog(Frame parent, String title) {
              super();
              this.parent = parent;
              this.setTitle(title);
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setModal(true);
              this.setSize(377, 246);
              this.setContentPane(getJContentPane());
              this.setVisible(false);
              this.setLocationRelativeTo(parent);
              this.addWindowListener(new java.awt.event.WindowAdapter() {
                   public void windowClosing(java.awt.event.WindowEvent e) {
                        selectedImage = null;
                        option = CANCEL_OPTION;
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private javax.swing.JPanel getJContentPane() {
              if(jContentPane == null) {
                   jLabel = new JLabel();
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(null);
                   jLabel.setBounds(87, 192, 58, 10);
                   jLabel.setText("Preview");
                   jContentPane.add(getPreviewPanel(), null);
                   jContentPane.add(jLabel, null);
                   jContentPane.add(getFilenameTextField(), null);
                   jContentPane.add(getBrowseButton(), null);
                   jContentPane.add(getCancelButton(), null);
                   jContentPane.add(getOkButton(), null);
              return jContentPane;
          * This method initializes previewPanel     
          * @return javax.swing.JPanel     
         private JPanel getPreviewPanel() {
              if (previewPanel == null) {
                   previewPanel = new JPanel();
                   previewLabel = new JLabel();
                   previewPanel.setLayout(null);
                   previewPanel.setLocation(25, 62);
                   previewPanel.setSize(172, 125);
                   previewPanel.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.LOWERED));
                   previewLabel.setText("");
                   previewLabel.setLocation(2, 2);
                   previewLabel.setSize(172, 125);
                   previewPanel.add(previewLabel, null);
              return previewPanel;
          * This method initializes jTextField     
          * @return javax.swing.JTextField
         private JTextField getFilenameTextField() {
              if (filenameTextField == null) {
                   filenameTextField = new JTextField();
                   filenameTextField.setBounds(26, 17, 212, 23);
                   filenameTextField.setEditable(false);
              return filenameTextField;
          * This method initializes jButton     
          * @return javax.swing.JButton     
         private JButton getBrowseButton() {
              if (browseButton == null) {
                   browseButton = new JButton();
                   browseButton.setBounds(254, 18, 102, 21);
                   browseButton.setText("Browse");
                   browseButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) { 
                             ImageFilter imageFilter = new ImageFilter();
                             fileChooser.setFileFilter(imageFilter);
                             int value = fileChooser.showOpenDialog(ImageChooserDialog.this);
                             if (value == JFileChooser.APPROVE_OPTION) {
                                  File selected = fileChooser.getSelectedFile();
                                  if (selected.canRead()) {
                                       try {
                                            BufferedImage bi = ImageIO.read(selected);
                                            selectedImage = bi;
                                            Image scaled = bi.getScaledInstance(
                                                      previewPanel.getWidth(), previewPanel.getHeight(), BufferedImage.SCALE_FAST);
                                            ImageIcon imageIcon = new ImageIcon(scaled);
                                            previewLabel.setIcon(imageIcon);
                                            filenameTextField.setText(selected.getAbsolutePath());
                                       } catch (IOException e1) {
                                            previewLabel.setText("Preview unavailable...");
                                            selectedImage = null;
                                            e1.printStackTrace();
              return browseButton;
          * This method initializes jButton1     
          * @return javax.swing.JButton     
         private JButton getCancelButton() {
              if (cancelButton == null) {
                   cancelButton = new JButton();
                   cancelButton.setBounds(254, 122, 100, 24);
                   cancelButton.setText("Cancel");
                   cancelButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             selectedImage = null;
                             option = CANCEL_OPTION;
                             ImageChooserDialog.this.dispose();
              return cancelButton;
          * This method initializes jButton2     
          * @return javax.swing.JButton     
         private JButton getOkButton() {
              if (okButton == null) {
                   okButton = new JButton();
                   okButton.setBounds(256, 159, 97, 24);
                   okButton.setText("OK");
                   okButton.addActionListener(new java.awt.event.ActionListener() {
                        public void actionPerformed(java.awt.event.ActionEvent e) {
                             option = OK_OPTION;
                             ImageChooserDialog.this.dispose();
              return okButton;
          * Displays this chooser dialog.
          * @return - The user selected option
          *                (i.e. OK_OPTION, CANCEL_OPTION)
         public int showDialog() {
              this.setVisible(true);
              return option;
          * Returns the image chosen by the user.
          * @return
         public Image getSelectedImage() {
              return selectedImage;
    import java.io.File;
    import javax.swing.filechooser.FileFilter;
    public class ImageFilter extends FileFilter {
        //Accept all directories and all gif, jpg, tiff, or png files.
        public boolean accept(File f) {
            if (f.isDirectory()) {
                return true;
            String extension = Utils.getExtension(f);
            if (extension != null) {
                if (extension.equals(Utils.tiff) ||
                    extension.equals(Utils.tif) ||
                    extension.equals(Utils.gif) ||
                    extension.equals(Utils.jpeg) ||
                    extension.equals(Utils.jpg) ||
                    extension.equals(Utils.png)) {
                        return true;
                } else {
                    return false;
            return false;
        //The description of this filter
        public String getDescription() {
            return "Just Images";
    * Created on Sep 24, 2006
    import java.awt.Image;
    * Contract that specifies how a class can update
    * the view in its graphical display.
    * @author Josh Feldman
    public interface ImageUpdater {
         public Image getSelectedImage();
    * Created on Nov 4, 2006
    import java.awt.Image;
    import java.awt.Toolkit;
    import java.awt.event.KeyEvent;
    import java.awt.image.BufferedImage;
    import java.io.File;
    import java.io.IOException;
    import java.rmi.Naming;
    import javax.imageio.ImageIO;
    import javax.swing.ImageIcon;
    import javax.swing.JButton;
    import javax.swing.JFrame;
    import javax.swing.JLabel;
    import javax.swing.JOptionPane;
    import javax.swing.JPanel;
    import javax.swing.JPasswordField;
    import javax.swing.JTextField;
    public class LoginFrame extends JFrame {
         private String serverName = "//Broom:5001/IMServer";
         private ServerInter serverInter = null;
         // The icon to be used when this frame is minimized
         private Image icon;
         // The main image to be displayed on this frame
         private Image robotImage;
         private javax.swing.JPanel jContentPane = null;
         private JPanel imagePanel = null;
         private JLabel screenameLabel = null;
         private JTextField screenameTextField = null;
         private JPanel jPanel1 = null;
         private JLabel passwordLabel = null;
         private JPasswordField passwordTextField = null;
         private JButton signonButton = null;
         private JButton helpButton = null;
          * This is the default constructor
         public LoginFrame() {
              initialize();
          * This method initializes this
          * @return void
         private void initialize() {
              this.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
              this.setResizable(false);
              this.setSize(210, 368);
              this.setContentPane(getJContentPane());
              this.setTitle("Sign On");
              try {
                   this.setIconImage(ImageIO.read(new File("images/robby3.jpg")));
              } catch (IOException e) {
                   e.printStackTrace();
              this.setLocationRelativeTo(null);
              this.setVisible(true);
          * This method initializes jPanel     
          * @return javax.swing.JPanel     
         private JPanel getImagePanel() {
              if (imagePanel == null) {
                   imagePanel = new JPanel();
                   imagePanel.setBounds(7, 7, 190, 159);
                   imagePanel.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,0));
                   try {
                        BufferedImage bi =
                             ImageIO.read(
                                       getClass().getClassLoader().getResourceAsStream("images/robby_big.bmp"));
                        Image scaled = bi.getScaledInstance(190, 169, BufferedImage.SCALE_FAST);
                        JLabel robotLabel = new JLabel(
                                  new ImageIcon(scaled));
                        imagePanel.add(robotLabel);
                   } catch (IOException e) {
                        e.printStackTrace();
              return imagePanel;
          * This method initializes jTextField     
          * @return javax.swing.JTextField     
         private JTextField getScreenameTextField() {
              if (screenameTextField == null) {
                   screenameTextField = new JTextField();
                   screenameTextField.setBounds(22, 208, 168, 20);
                   screenameTextField.addKeyListener(new java.awt.event.KeyAdapter() {  
                        public void keyTyped(java.awt.event.KeyEvent e) {
                             if (!isAllowedCharacter(e.getKeyChar())) {
                                  e.consume();
                                  Toolkit.getDefaultToolkit().beep();
                        public void keyPressed(java.awt.event.KeyEvent e) {
                             int keycode = e.getKeyCode();
                             if(keycode == KeyEvent.VK_ENTER && signonButton.isEnabled()) {
                                  signonButton.doClick();
                                  passwordTextField.setText("");
                             else if (keycode == KeyEvent.VK_ESCAPE) {
                                  dispose();
                                  System.exit(0);
                        public void keyReleased(java.awt.event.KeyEvent e) {
                             String screename = screenameTextField.getText();
                             char [] password = passwordTextField.getPassword();
                             if (screename.equals("") ||
                                       password.length <= 0) {
                                  signonButton.setEnabled(false);
                             else if (!screename.equals("") &&
                                       password.length > 0) {
                                  signonButton.setEnabled(true);
                             clearPasswordArray(password);
              return screenameTextField;
          * This method initializes jPanel1     
          * @return javax.swing.JPanel     
         private JPanel getJPanel1() {
              if (jPanel1 == null) {
                   jPanel1 = new JPanel();
                   jPanel1.setBounds(8, 173, 188, 1);
                   jPanel1.setBorder(javax.swing.BorderFactory.createLineBorder(java.awt.Color.gray,5));
              return jPanel1;
          * This method initializes jPasswordField     
          * @return javax.swing.JPasswordField     
         private JPasswordField getPasswordTextField() {
              if (passwordTextField == null) {
                   passwordTextField = new JPasswordField();
                   passwordTextField.setBounds(20, 259, 170, 20);
                   passwordTextField.addKeyListener(new java.awt.event.KeyAdapter() {
                        public void keyTyped(java.awt.event.KeyEvent e) {
                             if (!isAllowedCharacter(e.getKeyChar())) {
                                  e.consume();
                                  Toolkit.getDefaultToolkit().beep();
                        public void keyPressed(java.awt.event.KeyEvent e) {
                             int keycode = e.getKeyCode();
                             if(keycode == KeyEvent.VK_ENTER && signonButton.isEnabled()) {
                                  signonButton.doClick();
                                  passwordTextField.setText("");
                             else if (keycode == KeyEvent.VK_ESCAPE) {
                                  dispose();
                                  System.exit(0);
                        public void keyReleased(java.awt.event.KeyEvent e) {
                             String screename = screenameTextField.getText();
                             char [] password = passwordTextField.getPassword();
                             if (screename.equals("") ||
                                       password.length <= 0) {
                                  signonButton.setEnabled(false);
                             else if (!screename.equals("") &&
                                       password.length > 0) {
                                  signonButton.setEnabled(true);
                             clearPasswordArray(password);
              return passwordTextField;
          * This method initializes jContentPane
          * @return javax.swing.JPanel
         private javax.swing.JPanel getJContentPane() {
              if(jContentPane == null) {
                   passwordLabel = new JLabel();
                   screenameLabel = new JLabel();
                   jContentPane = new javax.swing.JPanel();
                   jContentPane.setLayout(null);
                   screenameLabel.setBounds(22, 182, 132, 20);
                   screenameLabel.setText("Screename");
                   screenameLabel.setEnabled(true);
                   screenameLabel.setFont(new java.awt.Font("Century Gothic", java.awt.Font.BOLD, 12));
                   passwordLabel.setBounds(21, 238, 135, 17);
                   passwordLabel.setText("Password");
                   jContentPane.add(getImagePanel(), null);
                   jContentPane.add(screenameLabel, null);
                   jContentPane.add(getScreenameTextField(), null);
                   jContentPane.add(getJPanel1(), null);
                   jCon                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             

  • JTree truncating entries (pictures) - help?

    I have written a Jabber client in Java, and am using a JTree to represent the buddies in the buddy list. The JTree dynamically removes and adds nodes as people sign on.
    This JTree is placed in a JScrollPane in case the JTree gets to big or wide.
    Every once in a while, someone will sign on (usually the first person that signs on), and the JLabel that represents the node is truncated with elipses (you can see what I mean by looking at this picture: http://linuxhelp.homeunix.com/JTree.png - I've circled the offending entry in red).
    How can I fix this?
    Thanks,
    Adam

    Hi,
    I still have the same problem.
    I use my own XXTreeModel that is derived from the DefaultTreeModel. It does not override any method from DefaultTreeModel but adds some convenience methods to add and remove nodes. These methods use the methods of the DefaultTreeModel.
    I tried to use JTree.setRowHeight(0) and also added some nodeChanged(..) calls. But it doesn't fix the problem completely. Its getting better but it doesn't disappear.
    Maybe it has something to do with the fact that I add about 100 nodes very fast.
    Does anyone have another idea what to do?
    Thanks
    Ulrich

  • How to make a Jtree expandable

    Hi have a JTree and when I expand the tree and catch an exption hence not adding any children I would like the node that I have expanded to autamatically be collapsed, and ready for a future expand, as I have a situation were a node in the tree might not yet have any children (the children will be added dynamically).
    I would like to handel the 9iexeption in such a way that the tree is ready for use and has the "+ sign available" to the user,
    at the moomemt it thincks there are no chldren and has no "+ " or "-" sign so no future expand is posible
    please help !!!!

    hentchocan wrote:
    I want to make a JTree that has a TextArea nodes. So each child when expanded shows a text area containing some information . Can any one provide example of such behaviour .
    Best Regards,Here the reply button works.

Maybe you are looking for