Hiding a intermediate node in a Jtree without hiding leaf nodes

Hi who can help me out of this problem. What my prob is dat i m interrested in hiding few intermediate nodes in JTree without hiding their children.
Thanks
Rakesh

but how do you then expand to see the children? once the node is hidden, can you by any means expand/collapse it to view/hide the child leaves?

Similar Messages

  • How to create JTree without root node

    Hello;
    I like to create a JTree without root node?
    Any help?
    Thanks!
    --tony                                                                                                                                                                                   

    javadocs JTree,
    setRootVisible
    public void setRootVisible(boolean rootVisible)
    Determines whether or not the root node from the TreeModel is visible.
    Parameters:
    rootVisible - true if the root node of the tree is to be displayedSee Also:
    rootVisible

  • Get node jtree without click

    hi all,
    I want get node from jtree without click, just with mouse in node.
    I look in google but dont find nothing...
    I try use listener but MousePressed dont help-me.
    thanks

    jTree1 = new JTree1(treeModel);Sorry, now
    jTree1 = new JTree(treeModel);
    MouseMotionListener mm = new MouseMotionListener(){
          public void mouseMoved(MouseEvent e) {
                System.out.println("moved "+e.getX()+" "+e.getY());
                 int selRow = jTree1.getRowForLocation(e.getX(), e.getY());
                TreePath selPath = jTree1.getPathForLocation(e.getX(), e.getY());
                if(selRow != -1) {
                                    System.out.println("mouse moved..."+selPath);
        public void mouseDragged(MouseEvent e) {
                   System.out.println("dragged "+e.getX()+" "+e.getY());
    jTree1.addMouseMotionListener(mm);
    jScrollPane1.setViewportView(jTree1);

  • Multiple Selection on JTree without holding down [CTRL] or [SHIFT]

    I need an example about how make multiple selection on JTree without holding down [CTRL] or [SHIFT].
    my JTree contains JCheckBox in any nodes, but I can't select two or more checkBox in time without holding down [CRTL] or [SHIFT].
    thanks for help.
    Jose A.

    I did this a few years ago so my newbiness is going to show through a bit, but I'm too lazy to update it.import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.*;
    public class Test3 extends JFrame {
      JTree jt = new JTree();
      MultiTreeSelectionModel mtsm = new MultiTreeSelectionModel(jt);
      JCheckBox multiCheck = new JCheckBox("Multi"),
          branchCheck = new JCheckBox("Branch");
      public Test3() {
        setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        JPanel content = (JPanel)getContentPane();
        multiCheck.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(ActionEvent e) {
                mtsm.setMultiSelect(multiCheck.isSelected());
        branchCheck.setText("Branch");
        branchCheck.addActionListener(new java.awt.event.ActionListener() {
          public void actionPerformed(ActionEvent e) {
                mtsm.setBranchSelect(branchCheck.isSelected());
        JPanel jp = new JPanel();
        jp.add(multiCheck);
        jp.add(branchCheck);
        content.add(jp, BorderLayout.NORTH);
        ActionListener specialKeyListener =
            new ActionListener() {
                public void actionPerformed(ActionEvent evt) {
                    MultiTreeSelectionModel.keyModifiers = evt.getModifiers();
        KeyStroke keyStroke;
        for (int i = 0; i < keys.length; i++) {
            keyStroke = KeyStroke.getKeyStroke(keys[0], 0, true);
    content.registerKeyboardAction(specialKeyListener, keyStroke,
    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    keyStroke = KeyStroke.getKeyStroke(keys[i][0], keys[i][1], false);
    content.registerKeyboardAction(specialKeyListener, keyStroke,
    JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
    jt.setSelectionModel(mtsm);
    content.add(new JScrollPane(jt), BorderLayout.CENTER);
    setSize(300, 300);
    setVisible(true);
    public static void main(String[] args) { new Test3(); }
    private static int[][] keys = {{KeyEvent.VK_CONTROL, ActionEvent.CTRL_MASK},
    {KeyEvent.VK_SHIFT, ActionEvent.SHIFT_MASK},
    {KeyEvent.VK_ALT, ActionEvent.ALT_MASK}};
    class MultiTreeSelectionModel extends DefaultTreeSelectionModel {
    static int keyModifiers;
    private boolean branchSelect, multiSelect;
    private JTree tree;
    private TreePath[] savePaths;
    MultiTreeSelectionModel(JTree Tree) {
    tree = Tree;
    setSelectionMode(TreeSelectionModel.DISCONTIGUOUS_TREE_SELECTION);
    private boolean isSelected(TreePath Path) {
    return tree.isPathSelected(Path) && (keyModifiers & KeyEvent.SHIFT_MASK) == 0;
    private boolean branchSelect() {
    return branchSelect || ((keyModifiers & KeyEvent.ALT_MASK) != 0);
    public void addSelectionPaths(TreePath[] paths) {
    if (branchSelect()) paths = getAllPaths(paths);
    super.addSelectionPaths(paths);
    public void removeSelectionPaths(TreePath[] paths) {
    if (branchSelect()) paths = getAllPaths(paths);
    super.removeSelectionPaths(paths);
    public void setSelectionPaths(TreePath[] paths) {
    if (branchSelect()) {
    paths = getAllPaths(paths);
    if (paths != null && paths.length > 0 && isSelected(paths[0])) {
    super.removeSelectionPaths(paths);
    } else if (multiSelect) super.addSelectionPaths(paths);
    else super.setSelectionPaths(paths);
    protected TreePath[] getAllPaths(TreePath[] paths) {
    if (paths == null || paths.length == 0) {
    return paths;
    Vector vector = new Vector();
    DefaultMutableTreeNode treeNode, thisNode;
    for (int i = 0; i < paths.length; i++) {
    if (paths[i] != null) {
    thisNode = (DefaultMutableTreeNode) paths[i].getLastPathComponent();
    Enumeration enumeration = thisNode.preorderEnumeration();
    while (enumeration.hasMoreElements()) {
    // add all descendants to vector
    treeNode = (DefaultMutableTreeNode) enumeration.nextElement();
    TreePath treePath = new TreePath(treeNode.getPath());
    vector.add(treePath);
    int i = vector.size();
    TreePath[] allpaths = new TreePath[i];
    for (int j = 0; j < i; j++) {
    allpaths[j] = (TreePath) vector.elementAt(j);
    return allpaths;
    protected void setMultiSelect(boolean b) { multiSelect = b; }
    protected boolean isMultiSelect() { return multiSelect; }
    protected void setBranchSelect(boolean b) { branchSelect = b; }
    protected boolean isBranchSelect() { return branchSelect; }
    protected void savePaths(TreePath Path) {
    TreePath[] tmpPaths = getSelectionPaths();
    if (tmpPaths == null) {
    savePaths = null;
    } else {
    int cnt = 0;
    for (int i = 0; i < tmpPaths.length; i++) {
    if (tmpPaths[i].isDescendant(Path)) {
    cnt++;
    savePaths = new TreePath[cnt];
    cnt = 0;
    for (int i = 0; i < tmpPaths.length; i++) {
    if (tmpPaths[i].equals(Path) || tmpPaths[i].isDescendant(Path)) {
    savePaths[cnt++] = tmpPaths[i];
    protected void restorePaths() {
    if (savePaths != null) {
    final DefaultTreeSelectionModel foo = this;
    SwingUtilities.invokeLater(
    new Runnable() {
    public void run() {
    foo.setSelectionPaths(savePaths);

  • Is there any way to display JTree without using applet

    Hi,
    is there any way to display JTree without using applet . Can we display the JTree in a JSP page.
    With Regards,
    Sheema.

    Not a JTree, per se. But there are Javascript solutions out there and there are JSP tag library solutions which use a JTree on the server side to hold and maintain the data and expanded nodes.
    This is one that I've used before, it's pretty good:
    http://www.jenkov.dk/treetag/introduction.tmpl

  • EXPAND INTERMEDIATE NODE OF TIME DIMENSION

    Hello!
    Can anybody help me? we created members for time dimension like this:
    2010.TOTAL
    ___2010.JAN
    ______2010.JAN.Q1
    ______2010.JAN.Q2
    If we try to expand, like a column, this dimension in a Report, adding the ID in the "MemberSet", it's only possible for the TOTAL and the Q1 or Q2. But It's not possible for de month directly. In that case we have an EVDRE error "invalid member in <memberset>"
    Anybody know what can I do to expand the intermediate node of the tree?
    Thank you very much!!
    Elena

    Hi Elena,
    In one of the empty cells, type the below formula
    =EVPRO($B$3,$B$23,"YEAR")&".JAN.F1,"&EVPRO($B$3,$B$23,"YEAR")&".JAN.F2,"&EVPRO($B$3,$B$23,"YEAR")&".FEB.F1,"&EVPRO($B$3,$B$23,"YEAR")&".FEB.F2,"&EVPRO($B$3,$B$23,"YEAR")&".MAR,"&EVPRO($B$3,$B$23,"YEAR")&".APR,"&EVPRO($B$3,$B$23,"YEAR")&".MAY,"&EVPRO($B$3,$B$23,"YEAR")&".JUN"
    Where B3 is the cell with the application name
    B23 is the cell with the time member
    EVPRO($B$3,$B$23,"YEAR") is going to fetch the year from the member in the cell B23
    Once you have entered the above formula in an empty cell, and if you have 2010.JAN in the cell B23, then your cell should display the value as
    2010.JAN.F1,2010.JAN.F2,2010.FEB.F1,2010.FEB.F2,2010.MAR,2010.APR,2010.MAY,2010.JUN
    In the memberset of the time dimension, refer to the cell in which you have entered the above formula.
    Hope this helps.

  • The Parent-Child Hierarchy can't be queried in any intermediate node

    Hi All,
    I've created a Parent-Child Hierarchy with Obiee 11g(11.1.1.3).
    I can use the filter to select any Root-Node and it can be expanded correctly.But if I choose any intermediate node,it can't be expanded.Then what can I do?
    Thanks in advance!
    Edited by: Needn on 2011-9-8 下午8:42

    Thx for your advice,but my qusetion has not been solved.
    I don't know how to use these function in the analytics page.Must I modify its default SQL and apply mine?
    Its default SQL like the following ,then how can I modify it to achieve my purpose?
    SELECT s_0, s_1, s_2, s_3, s_4 FROM (
    SELECT
    *0 s_0,*
    *"model"."DIM_PROD_COST_CATEGORY"."CATEGORY_NAME" s_1,*
    CASE WHEN ISLEAF("model"."DIM_PROD_COST_CATEGORY"."DIM_PROD_COST_CATEGORYDim") THEN 1 ELSE 0 END s_2,
    IDOF("model"."DIM_PROD_COST_CATEGORY"."DIM_PROD_COST_CATEGORYDim") s_3,
    PARENT("model"."DIM_PROD_COST_CATEGORY"."DIM_PROD_COST_CATEGORYDim") s_4
    FROM "model"
    WHERE
    ISROOT("model"."DIM_PROD_COST_CATEGORY"."DIM_PROD_COST_CATEGORYDim")
    *) djm ORDER BY 1*

  • Perform drag&drop in Jtree without even selecting a node once?

    Hi All,
    Is it possible to perform drag and Drop action on tree nodes even when the Jtree is not active.
    That is, say a jtree is not active and i directly want to drag a node inside it without even selecting it once?
    Thanks alot in Advance.

    You should google for "jtree drag and drop". I remember seeing a very nice tutorial on codeproject.
    If your run into any specific issue let me know.

  • How to use custom nodes in a JTree without reinventing the wheel?

    Hello,
    Each node contains two JTextAreas in a Box layout and a few JButtons.
    I wish to display these nodes in a JTree.
    Reading the tutorial, it seems I would have to reimplement the TreeModel, TreeCellRenderer/Editor, MutableTreeNode interfaces etc.
    Can I use the DefaultTreeModel, and other standard widgets (great stuff!) to minimize the amount of reimplementation I must do. aka avoid reinventing the wheel? I was thinking of extending my node from the DefaultMutableTreeNode class - however it does not display the nodes with the TextAreas, buttons etc.
    any help appreciated.
    thanks,
    Anil

    was able to fix it over here:
    http://forum.java.sun.com/thread.jspa?messageID=4089777

  • Can I move nodes in a jTree without the mouse?

    I want to move nodes in a jTree as if I was dragging and dropping but I don�t want to use the mouse. Is this possible and how.

    I want to move nodes in a jTree as if I was dragging
    and dropping but I don�t want to use the mouse. Is
    this possible and how.sure it's possible through the power of Java(tm)

  • How to select node in JTree without firing event?

    I have got standard situation. JTree in the left panel, and several edit boxes in right panel. Certainly, I have TreeSelectionListener, which on every tree node selection shows corresponding model values in edit boxes.
    I'd like to implement next logic:
    1. Something was changed in any edit box in right panel. Model has been changed.
    2. User clicks on different node in tree.
    3. Dialog "Message was not saved. Save?" with Yes/No/Cancel buttons are shown.
    Yes/No buttons are easy to handle.
    Question is about Cancel. I'd like on Cancel button left all edit boxes in their present state (do not restore values from saved model) and select back node, which wasn't saved.
    Problem is next. If I select node by setSelectionPath or smth like that, but... JTree fires event and my listener receives onTreeItemSelected back, which checks that node wasn't saved and ......
    Who does have any idea, or have done similar tasks? How can I select node and do not allow tree fire event this time?
    Thanks in advance.

    First, as soon as the model changes (when editing any
    combo box) some flag will be set. Now the logic which
    updates the combo boxes will do it only on a change of
    the current node and (this is new) if the flag wasn't
    set. You should have some flag anyway because somehow
    you must determine when to show the dialog, shouldn't
    you?Yes, I have got this logic implemented. But it's only the half :)
    I know exactly when my model has been changed, but if it was changed, i'd like to ask user what to do next - svae/loose changes/cancel
    And on cancel i'd like to select last edited tree node and do not get event from tree at that moment.
    >
    Second way, prevent selecting a new node if that flag
    has been set. You could do this by subclassing
    DefaultTreeSelectionModel and overriding some methods
    (setSelectionPath() et al).Ok. I'll investigate this.
    >
    MichaelThanks.

  • Hiding leaf node from jtree ?

    Hi,
    How can I hide all nodes that are leafs on a tree?
    Basically, I'm creating a splitpane where on the left side I have a jtree where when a user clicks on a node ( as a folder ) on that jtree the leaf nodes ( all the children nodes of the selected node ) will appear on the right split pane as icons.
    thanks in advance!

    Define your own renderer class eg:
    class NavTreeCellRenderer extends DefaultTreeCellRenderer {
    public Component getTreeCellRendererComponent(JTree tree, Object value,
    boolean sel,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus)
    if(leaf == true){
    this.setPreferredSize(new Dimension(0, 0));
    super.getTreeCellRendererComponent(tree, dto.getNodeLabel(), sel, expanded, true, row, hasFocus);
    return this;
    Then set this rederer to ur tree
    NavTreeCellRenderer navTCR = new NavTreeCellRenderer();
    jTree.setCellRenderer(navTCR);
    And then ENJOY

  • Selcting Multiple  CheckBoxe in a JTREE without holding CTRL / SHIFT

    HI,
    My JTree is having JCheckBOxes as nodes .... Now the problem is i want to select multiple nodes (checkboxes) with out holding CTRL/SHIFT key .
    Please help regarding this issue ..
    The code of my renderer class is as below:
    * MyTreeRendered.java
    * Created on April 27, 2006, 7:42 PM
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    public class MyTreeRendered extends DefaultTreeCellRenderer  {
        private JCheckBox cb ;
        /** Creates a new instance of MyTreeRendered */
        public MyTreeRendered() {
        public Component getTreeCellRendererComponent(
                            JTree tree,
                            Object value,
                            boolean sel,
                            boolean expanded,
                            boolean leaf,
                            int row,
                            boolean hasFocus){
           if(cb == null) {
               cb = new JCheckBox();
               cb.setBackground(tree.getBackground());
           DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
           cb.setText(node.getUserObject().toString());
           cb.setSelected(sel);
           return cb;
    }

    These are the methods which seem to define that behaviour:
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/basic/BasicTreeUI.html#isToggleSelectionEvent(java.awt.event.MouseEvent)
    http://java.sun.com/j2se/1.5.0/docs/api/javax/swing/plaf/basic/BasicTreeUI.html#isMultiSelectEvent(java.awt.event.MouseEvent)
    You'd have to write your own TreeUI and override them.

  • Updating a JTree without application restart

    I would like to update the JTree in my application without restarting the application. The JTree elements come from a file, therefore, I update the file and want the JTree to be refreshed! I understand that this is done with swing and model and already do so eg: I update combo boxes and these automatically reflect the changes. I use the code below to update the boxes:-
    public void updateBoxes()
    DefaultComboBoxModel newComboModel = new DefaultComboBoxModel(getItems());
    myBox.setModel(newComboModel);
    I would basically like to do exactly the same using another model for a JTree.  Is this possible?  Also, as the JTree has actually been added to a scroll panel, so does this affect things?  Hopefully I can use a simple method like the one provided above for updaing a combo box.
    Thanks for any assistance

    * TestTree.java
    package com.test;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class TestTree extends javax.swing.JFrame {
        private javax.swing.JScrollPane mainScrollPane;
        private javax.swing.JButton btnChooseThree;
        private javax.swing.JTree mainTree;
        private javax.swing.JButton btnChooseOne;
        private javax.swing.JPanel buttonPanel;
        private javax.swing.JButton btnChooseTwo;
        public TestTree() {
            java.awt.GridBagConstraints gridBagConstraints;
            mainScrollPane = new javax.swing.JScrollPane();
            mainTree = new javax.swing.JTree();
            buttonPanel = new javax.swing.JPanel();
            btnChooseOne = new javax.swing.JButton();
            btnChooseTwo = new javax.swing.JButton();
            btnChooseThree = new javax.swing.JButton();
            addWindowListener(new java.awt.event.WindowAdapter() {
                public void windowClosing(java.awt.event.WindowEvent evt) {
                    exitForm(evt);
            mainScrollPane.setViewportView(mainTree);
            getContentPane().add(mainScrollPane, java.awt.BorderLayout.CENTER);
            buttonPanel.setLayout(new java.awt.GridBagLayout());
            btnChooseOne.setText("One");
            btnChooseOne.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseOne.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseOne.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseOne.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseOneActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseOne, gridBagConstraints);
            btnChooseTwo.setText("Two");
            btnChooseTwo.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseTwo.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseTwoActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseTwo, gridBagConstraints);
            btnChooseThree.setText("Three");
            btnChooseThree.setMaximumSize(new java.awt.Dimension(70, 27));
            btnChooseThree.setMinimumSize(new java.awt.Dimension(70, 27));
            btnChooseThree.setPreferredSize(new java.awt.Dimension(70, 27));
            btnChooseThree.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    btnChooseThreeActionPerformed(evt);
            gridBagConstraints = new java.awt.GridBagConstraints();
            gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
            buttonPanel.add(btnChooseThree, gridBagConstraints);
            getContentPane().add(buttonPanel, java.awt.BorderLayout.NORTH);
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Three");
            rootNode.add(new DefaultMutableTreeNode("One"));
            rootNode.add(new DefaultMutableTreeNode("Two"));
            rootNode.add(new DefaultMutableTreeNode("Three"));
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
            pack();
        private void btnChooseThreeActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Three");
            rootNode.add(new DefaultMutableTreeNode("One"));
            rootNode.add(new DefaultMutableTreeNode("Two"));
            rootNode.add(new DefaultMutableTreeNode("Three"));
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void btnChooseTwoActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("Two");
            DefaultMutableTreeNode subNode;
            subNode = new DefaultMutableTreeNode("One");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Two");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Three");
            subNode.add(new DefaultMutableTreeNode("Sub One"));
            subNode.add(new DefaultMutableTreeNode("Sub Two"));
            subNode.add(new DefaultMutableTreeNode("Sub Three"));
            rootNode.add(subNode);
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void btnChooseOneActionPerformed(java.awt.event.ActionEvent evt) {
            DefaultMutableTreeNode rootNode = new DefaultMutableTreeNode("One");
            DefaultMutableTreeNode subNode;
            DefaultMutableTreeNode subSubNode;
            subNode = new DefaultMutableTreeNode("One");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Two");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            subNode = new DefaultMutableTreeNode("Three");
            subSubNode = new DefaultMutableTreeNode("Sub One");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub A"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub B"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub C"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Two");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 1"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 2"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub 3"));
            subNode.add(subSubNode);
            subSubNode = new DefaultMutableTreeNode("Sub Three");
            subSubNode.add(new DefaultMutableTreeNode("Very Sub X"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Y"));
            subSubNode.add(new DefaultMutableTreeNode("Very Sub Z"));
            subNode.add(subSubNode);
            rootNode.add(subNode);
            mainTree.setModel(new javax.swing.tree.DefaultTreeModel(rootNode));
        private void exitForm(java.awt.event.WindowEvent evt) {
            System.exit(0);
        public static void main(String args[]) {
            new TestTree().show();
    }

  • JTree without expand/collapse icons

    I want to be able to hide or change the expand/collapse icon of a specific node, not the entire Jtree.
    Is there any way to do that?
    Tahnx

    I want to be able to hide or change the expand/collapse icon of a specific node, not the entire Jtree.
    Is there any way to do that?
    Tahnx

Maybe you are looking for

  • Back up data on Z 22 to computer--Windows 7

    when I try to back up my Z22 to hard drive on windows 7, I receive a message "Error Modem Not foundf Ox1106.

  • Error message when 'submitting' completed survey.

    One survey participant got an error message as she was submitting the filled survey online. The message told her to press "back" on her browser and resubmit. She did that and it threw her back onto the first page of the survey... any ideas what is wr

  • Redownloading Acrobat 9.0 Standard

    I do computer work in my home. A customer needed a new hard drive. I want to download and install Acrobat for her. She does not have a backup copy unfortunately. According to her the software was purchased after she got the computer so it's not OEM.

  • Web Service to retrieve report

    I am trying to use the web services to retrieve a report's metadata, in particular the report filters. I can't find in the documentation the right classes/methods to use. In Jdeveloper, I have set up web service proxy for the WEBCatalogService, as we

  • Update JDK environment variables...

    Oracle 11g RAC RHEL 4 AS I have just upgraded JDK from 1.4 to 6.0 and I wanted to know where and which environment variables need to be updated. Thanks.