Can I  Have JTable As Leaf Node Of A JTree?

Hello there,
I want to show jtable on a click of a node of a tree. I have seen Treetable utlility on SUN's site. But it not quite what i want.
Does any one have any idea how to show JTable as a leaf node of a JTree.
E.g There is a tree called Components. viz.
Component
|Node1
|Node2
On click of Node1 i should see Table1 and on click of Node2 i should see Table2.
If anyone has any idea, can you explain how to do it Or some site name where help on this problem is available?
Please mail back.
Regards,
Amit

I used insertNodeInto() to inser a new node into the tree, and it can be displayed. But when I used addTreeSelectionListener() to click on the newly added node, it cann not reaspond the click. Following is my original addTreeSelectionListener(). You see, if you click a node of FARInfo, then it will open a form, and after user filled in and submit it, a new node will be added into the Jtree. If you click a node of FilledInfo, then the user should view the content of this new node. But now, it seems that the sencond click cannot work. Thanks for your help.
tree.addTreeSelectionListener( new TreeSelectionListener()
public void valueChanged(TreeSelectionEvent e4)
DefaultMutableTreeNode node = ( DefaultMutableTreeNode )
(tree.getLastSelectedPathComponent ());
Object nodeInfo = node.getUserObject();
if (node.isLeaf())
if ( nodeInfo instanceof FARInfo )
FARInfo category = (FARInfo) nodeInfo;
displayURL ( category.categoryURL );
displayForm ( category.farFormName );
if ( DEBUG )
System.out.print ( category.categoryURL + ":\n" );
else if ( nodeInfo instanceof FilledInfo )
FilledInfo category2 = ( FilledInfo ) nodeInfo;
displayFilledForm ( category2.num );
}else
return;

Similar Messages

  • Identifying leaf node in a JTree

    I have a single selection JTree which was constructed using DefaultTreeModel.
    asksAllowsChildren is set to 'true' in the tree model.
    The nodes in the model are constructed using DefaultMutableTreeNode and each
    node is marked if it allows children or not.
    How can I find if a selection is a leaf node or not.
    Thanks.

    Answering my own post, solution is:
    tree.getModel().isLeaf(tree.getSelectionPath().getLastPathComponent())
    where tree is the JTree object.

  • Can the name of a specific node in a JTree be returned by MouseEvent?

    I have created a mouseListener for a JTree. When a node in the JTree is clicked it should display the name of the node in a JOptionPane. Currently, I have the following:
    tree.addMouseListener(new MouseAdapter()
    public void mouseClicked(MouseEvent me)
         if(me.getClickCount() % 2 == 0)
         String s = "Blank";
         s = (me.getSource()).toString();
         JOptionPane.showMessageDialog(null, "Double clicked "+ s, "two", JOptionPane.PLAIN_MESSAGE);               
    }//mouseClicked          
    });//MouseListener
    This gives me the class X Y value, border, maxsize, etc.... when a node is double clicked.
    Does anyone know of a better way?

    Don't use MouseListener.
    Instead, make yourself a TreeSelectionListener as follows:
    public class WhererverYourTreeIs implements TreeSelectionListener
         public void valueChanged(TreeSelectionEvent e)
             TreePath path = e.getPath();
             System.out.println(path.getLastPathComponent());
         public void initStuff()
                 tree.addTreeSelectionLIstener(this);
    }

  • Selectable JTable as leaf node in JTree

    I've created a TreeCellRenderer that renders a JTable for nodes of type TableNode. The actual rendering seems to work fine, but the problem is that I am unable to select the rows in the JTable. I tried using a JTable-based TreeCellEditor, but that wasn't what I needed either. I don't need to edit the data, but only select an individual row so I can get its data to display in another panel on the screen.
    Any ideas?
    private class TableTreeCellRenderer extends DefaultTreeCellRenderer {
       private JTable table = new JTable();
       private DefaultTableModel model = (DefaultTableModel) table.getModel();
       public Component getTreeCellRendererComponent(JTree tree,
                                            Object value,
                                            boolean selected,
                                            boolean expanded,
                                            boolean leaf,
                                            int row,
                                            boolean hasFocus) {
         if (value instanceof TableNode) {
               TableNode node = (TableNode) value;
            model.setDataVector(node.getData(), node.getHeaders());
            JScrollPane js = new JScrollPane(table);
            js.setPreferredSize(getTableSize(table));
            return js;
         return super.getTreeCellRendererComponent(tree,
                                                      value,
                                          selected,
                                          expanded,
                                          leaf,
                                          row,
                                          hasFocus);
       private Dimension getTableSize(JTable table) {
          return null;
    }

    A renderer isn't a component which is added to a parent (tree in this case). It is only used for display purposes. You might try a [url http://java.sun.com/products/jfc/tsc/articles/treetable1/index.html]TreeTable.

  • How can I view the newly added node in a JTree

    Hi! I have a problem with my project. I set up a JTree. At first it has a node that contains FARInfo object. When I click this node, the other program in the package will pop up a form to let user input and submit, then it will add a new node into the other node. The new node will contain FilledInfo object. But I cannot view this newly added node. The source code related with the 2 different object is as following:
    tree.addTreeSelectionListener( new TreeSelectionListener()
    public void valueChanged(TreeSelectionEvent e4)
    DefaultMutableTreeNode node = ( DefaultMutableTreeNode )
    (tree.getLastSelectedPathComponent ());
    Object nodeInfo = node.getUserObject();
    if (node.isLeaf())
    if ( nodeInfo instanceof FARInfo )
    FARInfo category = (FARInfo) nodeInfo;
    displayURL ( category.categoryURL );
    displayForm ( category.farFormName );
    if ( DEBUG )
    System.out.print ( category.categoryURL + ":\n" );
    else if ( nodeInfo instanceof FilledInfo )
         FilledInfo category2 = ( FilledInfo ) nodeInfo;      
         displayFilledForm ( category2.num );
    }else
    return;
    My question is: how to deal with the nodes containing 2 different objects: FARInfo and FilledInfo? FilledInfo is created by the other program in the package. Thanks for your help!

    I used insertNodeInto() to inser a new node into the tree, and it can be displayed. But when I used addTreeSelectionListener() to click on the newly added node, it cann not reaspond the click. Following is my original addTreeSelectionListener(). You see, if you click a node of FARInfo, then it will open a form, and after user filled in and submit it, a new node will be added into the Jtree. If you click a node of FilledInfo, then the user should view the content of this new node. But now, it seems that the sencond click cannot work. Thanks for your help.
    tree.addTreeSelectionListener( new TreeSelectionListener()
    public void valueChanged(TreeSelectionEvent e4)
    DefaultMutableTreeNode node = ( DefaultMutableTreeNode )
    (tree.getLastSelectedPathComponent ());
    Object nodeInfo = node.getUserObject();
    if (node.isLeaf())
    if ( nodeInfo instanceof FARInfo )
    FARInfo category = (FARInfo) nodeInfo;
    displayURL ( category.categoryURL );
    displayForm ( category.farFormName );
    if ( DEBUG )
    System.out.print ( category.categoryURL + ":\n" );
    else if ( nodeInfo instanceof FilledInfo )
    FilledInfo category2 = ( FilledInfo ) nodeInfo;
    displayFilledForm ( category2.num );
    }else
    return;

  • Can I have RAC 1st node in RHEL 5 and 2nd node in RHEL 4?

    Can I have my RAC 1st node in RHEL5 and 2nd node in RHEL 4?
    I am just checking if there is any possibility like that.
    Thanks,
    Mahi

    Even if it works by accident, it wouldn't be supported.

  • Leaf nodes in Flex cluster

    Hi,
      can somebody explain what leaf nodes in flex cluster are?from documentation I see that they are nodes which dont have access to storage and they communicate with hub nodes.
      Can they have oracle db instances?If so how is data transfered between hub and leaf nodes?Through interconnect?Doesn't it overload the interconnect?
    Thanks
    Sekar

    Sekar_BLUE4EVER wrote:
    Thanks Aman...Still confused about this...Consider the following scenario
    |       H1       |<------->  |        H2         |   <------> |       H3        |
    |                   |              |                      |               |                    |
    | L1  L2  L3  |              | L1   L2   L3   |               | L1  L 2 L3   |
    | _________|              |___________|               |__________|
    H depicts the hub nodes and L depict the leaf nodes.Assume each Hub node has 3 leaf nodes attached to them.
    Suppose L1 connected to H1 needs a block and modifies it and after sometime L1 connected to H2 needs the same block then it must follow the same 2 way/3 way grant as in normal cache fusion right?
    Does this actually increase the number of hops since the leaf nodes are not directly connected?
    Do we have any control over the leaf node to hub node mapping or is it all automatically managed?
    Thanks
    The blocks are going to be accessed, modified at the Hub nodes only AFAIK as the Hub nodes are considered as DB Nodes. The Leaf Nodes are going to be considered as the Application Nodes. That's the reason, it's better to set up the instances running on the Hub Nodes only rather than the Leaf Nodes. Even if the instance runs on a Leaf Node, the communication is between the Hub and Leaf node only and it won't do any harm as both the nodes-Hub and Leaf(and the other nodes in the Leaf group) would be talking to each other directly. There is no VIP required on the Leaf Nodes so the connections by the database users would be only on the Hub Nodes, I guess and that means, the block movement would remain essentially the same.
    The number of network hops are reduced as you won't be having a requirement to have too many Hub Nodes since each Hub node can connect to  64(?) Leaf Nodes. So essentially, in your case, you would need only 4 Interconnects (2 on one Hub Node and 1 each on the remaining two) for the private interconnect and just 3 network links for the storage for each Hub node.
    I am not sure that I understood the last question of yours.
    HTH
    Aman....

  • How edit/focus/resize columns of JTable that is node of JTree?

    I have added a JTable as a node on a JTree, but now I can't interact with it. I think that it is because all mouse/selection actions are grabbed by the JTree. However, I can't figure out how to pass these on to the table.
    What method do I call? I can't seem to find a way to get which column I have clicked over, and even if i did, i can't find a method to actually select it!
    please help!

    Hi,
    your questions I had got some time ago, and I solved the problem . It means you will as well.

  • Highlighting nodes in a JTree

    Hi,
    I'd like to know how I can produce the efect of highlighting nodes in a JTree when the mouse moves over the JTree.
    Thanks

    You say to get the mouseevent coordinates with a mouse
    listener, but which component should be the caller of
    the methos addMouseListener?
    If I choose the jtree, I can't get the 'mouseevent
    coordinates' each time the mouse moves over a node,
    because the methods mouseEntered and mouseExited are
    invoked just once (when the mouse enter inside the
    jtree's area (mouseEntered), and when the mouse gets
    out the jtree's area(mouseExited)), so I can't change
    the boolean field to true for nodes which have the
    mouse over.just use mouseMoved of the MouseMotionListener.
    however, i have my doubts that you will have a lot of fun with the suggested method (correct though it is).
    at least make sure you only call the repaint method if the mouse moved into a new node. you might want to try the the nodeChanged method, that way you don't repaint the whole tree every time.
    thomas

  • Disk Utilities can not repair my disk - invalid node structure. How can I repair my disk? I have restarted with the CD.

    Hi,
    How can I repair my hard disk. Computer Starts up and then shuts down.
    I've started up with the CD and disk utilities can not fix the disk, invalid node error.
    How can I fix my disk?
    I need to get to the file on the hard disk.
    Thanks
    Peter

    With Disk Warrior can I start with a CD/DVD and get at the files on the hard disk?
    With apple disk utilites I can not see my files that are on the hard disk.
    If I could get at my files I could back them up and reformat my hard disk.

  • How to Find the node or leaf node selected in Tree UI element:

    Hi All,
    I have a tree structure with three level design. We have a button, which will perform some operation on the specific node or leaf node on every level.
    When we select any node or leaf node, we have action Onction getting called.  But what we want is that, after we select the node or leaf node,  we press a button below the tree design and perform some operation on the node selected.
    But how to get information that on Application , which node or leaf node has been slected ?
    Thanks
    PG

    Hi,
    Found the solution.
    Juts keep on reading all the nodes, system gives the complete path of the tree by using Lead selection and then we can use this path to peform the update operation on tree structure.
    Thanks alot for the hint.
    Regards
    PG

  • ADF TreeTable - How to hide Disclose/Expand icon for leaf node

    We are using ADF Tree Table in our application.
    Whenever a node is expanded - all the child nodes have the disclose/expand icon along with it.
    But, we don't want to show the disclose/expand icon if it is a leaf node.
    How can this be done?
    JDeveloper Version: JDeveloper 11.1.1.3
    Thanks,
    Navaneeth

    I have a hierarchical tree based on single POJO based class exposed as data control.
    (i.e) a node can have many levels.
    Can you specify how we can use the folder icon for this - Can you please provide some detailed information?
    Thanks in advance,
    Navaneeth

  • Hierarchy VIewer - Card only on Leaf nodes

    I am using version 11.1.2.3.0.
    Is there a way to show a Card only on the leaf nodes of the Hierarchy VIewer?
    I have information that only applies to the nodes on the very bottom of the tree.
    Thanks in advance.

    This should be possible.
    I've not tested this but you can use the rendered property of the panelCard component and set it to an EL which evaluates to false is the node has children (node.hasChildren? or some other data which lets you know if you want to show the card).
    If this does not work you leaf the rendered property as is and use the visible or rendered property of the component which holds the information you only want to show in leaf nodes.
    Timo

  • Hierarchical query - Stop at specific leaf nodes - How to in Oracle 9i ?

    Table H -- Master table to build Hierarchical tree
    C -- Child
    P -- Parent
    Table RN -- Table defining Root Nodes
    N -- Node
    Table LN -- Table defining Leaf Nodes
    N -- Node
    The following Query can generate trees starting with the nodes specified in the Table:RN
    SELECT LEVEL L, C, P, SYS_CONNECT_BY_PATH(C,'/') SCBP
    FROM H
    START WITH C IN ( SELECT N FROM RN )
    CONNECT BY PRIOR C = P
    How do I limit the tree to the nodes specified in the LN table ?
    "CONNECT BY" does not support "IN" clause
    i.e
    CONNECT BY PRIOR C = P AND P NOT IN (SELECT N FROM LN)
    Say we have 2 trees
    1-2-3-4-5
    A-B-C-D-E
    RN : 2,B
    LN : 5,D
    Result:
    2,3,4 (5 is excluded)
    B,C (D is excluded)
    Any help is appreciated...

    What about:
    select level l, c, p, sys_connect_by_path(c,'/') scbp
      from (select * from h
             where c not in (select n from ln))  -- filter via an inline view
    start with c in ( select n from rn )
    connect by prior c = p;

  • Can we use JTable in a JTree?

    Hi Actually this is my first mail to this forum.
    I want to use a tables embedded in a tree . You can see such format in VB's Properties sheet's "Categorized" tab. Has anyone tried doing such format. Or anyone knows if it is possible to do it in Jtrees. If yes then how?
    Anybody knows? Pls mail back.
    Regards,
    Amit.

    Hi,
    Thanks for the reply. This will definately serve my purpose, but i cannot compromise on the GUI. But, Is there a way by which I can have table on the click of a tree node and not JTree as a renderer for the cells in a JTable.
    Pls mail back.
    Regards,
    Amit

Maybe you are looking for