CheckBoxTree stack overflow.

This is the forum for JIDE Common Layer which is open sourced at https://github.com/jidesoft/jide-oss. Please note, JIDE technical support doesn't monitor this forum as often as other forums. Please consider subscribe for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

Moderator: JIDE Support

Forum rules
Community driven forum for open source JIDE Common Layer. JIDE technical support doesn't monitor this forum as often as other forums. If you only use JIDE Common Layer, please consider subscribing for technical support for JIDE Common Layer so that you can use customer only forum to get a timely response.

CheckBoxTree stack overflow.

Postby Thomas Corbin » Tue Dec 22, 2009 7:19 pm

Basically, to reproduce, you just run the program and click one of the
checkboxes. This is a problem with CheckBoxTree's 'dig in' mode in which
it selects the parent node if all of the child nodes are selected. But,
if you programmatically select the child nodes and not just the parent
node, it causes this stack overflow.

Code: Select all
import java.awt.Frame;
import java.util.Enumeration;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

import com.jidesoft.swing.CheckBoxTree;
import com.jidesoft.swing.CheckBoxTreeSelectionModel;

/**
 * TO REPRODUCE BUG:
 *
 * Run this code, click on a checkbox, wait for stack overflow error in
 * AWT event queue.
 *
 * Exception in thread "AWT-EventQueue-0" java.lang.StackOverflowError
        at java.util.AbstractCollection.<init>(AbstractCollection.java:49)
        at java.util.AbstractSet.<init>(AbstractSet.java:46)
        at java.util.HashSet.<init>(HashSet.java:85)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.addSelectionPaths(Unknown Source)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.isPathSelected(Unknown Source)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.addSelectionPaths(Unknown Source)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.isPathSelected(Unknown Source)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.addSelectionPaths(Unknown Source)
        at com.jidesoft.swing.CheckBoxTreeSelectionModel.isPathSelected(Unknown Source)
        ...
 */

@SuppressWarnings( "serial" )
public class CheckBoxTreeBug extends JPanel
{
    CheckBoxTreeBug()
    {
        DefaultMutableTreeNode root = new DefaultMutableTreeNode( "Contents" );

        root.add( new DefaultMutableTreeNode( "Llama" ) );
        root.add( new DefaultMutableTreeNode( "Aardvark" ) );
        root.add( new DefaultMutableTreeNode( "Platypus" ) );
        root.add( new DefaultMutableTreeNode( "Rutabaga" ) );
       
        DefaultTreeModel treeModel = new DefaultTreeModel( root );
        CheckBoxTree tree = new CheckBoxTree( treeModel );
        CheckBoxTreeSelectionModel selmodel = tree.getCheckBoxTreeSelectionModel();
       
        //
        //    Select all child nodes of the root
        //
        Enumeration<?> kids = root.children();       
        while( kids.hasMoreElements() )
        {
            DefaultMutableTreeNode kid = (DefaultMutableTreeNode) kids.nextElement();           
            selmodel.addSelectionPath( new TreePath( kid.getPath() ) );
        }
       
        add( tree );
    }
   
    public static void main( String[] args )
    {
        JDialog    dialog = new JDialog( (Frame) null, "CheckBoxTreeBug" );

        dialog.setDefaultCloseOperation( JDialog.DISPOSE_ON_CLOSE );
        dialog.getContentPane().add( new CheckBoxTreeBug() );
        dialog.pack();
        dialog.setVisible( true );
    }
}

Thomas Corbin
 
Posts: 2
Joined: Tue Nov 10, 2009 7:16 pm

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Wed Dec 23, 2009 10:33 am

This is an issue introduced while we tried to improve the selection performance. We will fix it in 2.8.3.

For now, please try the following code in your test case for workaround.
Code: Select all
        for (int i = 1; i < 5; i++) {
            selmodel.setBatchMode(true);
            selmodel.addSelectionPath( tree.getPathForRow(i) );
            selmodel.setBatchMode(false);
        }

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Fri Jan 29, 2010 12:26 pm

Just so you know, this is fixed in 2.8.3.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: CheckBoxTree stack overflow.

Postby fcarballo » Wed Feb 24, 2010 8:25 am

Hi, I'm having the same problem. I downloded the version 2.8.4 and 2.8.3 but it didn't works. Thomas, did you fix it with the new version?
fcarballo
 
Posts: 2
Joined: Wed Feb 24, 2010 8:21 am

Re: CheckBoxTree stack overflow.

Postby Thomas Corbin » Wed Feb 24, 2010 9:02 am

Sorry, no - I haven't downloaded 2.8.3 yet.

I'll try to do it sometime this week, though I'm busy.

I never enjoy downloading new versions, it always seems like a pain.
Thomas Corbin
 
Posts: 2
Joined: Tue Nov 10, 2009 7:16 pm

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Wed Feb 24, 2010 10:37 am

Looks like it is still broken. Sorry about that. We will figure out a solution for you in 2.8.5 and 2.9.0.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: CheckBoxTree stack overflow.

Postby fcarballo » Fri Feb 26, 2010 1:51 pm

Hi, I saw that this issue was fixed on trunk and I download trunk source, and work. But I get a new problem.
I'm trying to generate some checkbox triggers, so, when I click on checkbox 3 I want that checkbox 2 appears checked.
Here is my example code:
Code: Select all
import java.awt.Frame;

import javax.swing.JDialog;
import javax.swing.JPanel;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;
import javax.swing.tree.DefaultTreeModel;
import javax.swing.tree.TreePath;

import com.jidesoft.swing.CheckBoxTree;
import com.jidesoft.swing.CheckBoxTreeSelectionModel;

@SuppressWarnings("serial")
public class CheckBoxTreeSimpleBug extends JPanel {

   private CheckBoxTree tree = null;

   private CheckBoxTree getCheckBoxTree() {
      return tree;
   }

   CheckBoxTreeSimpleBug() {
      DefaultMutableTreeNode root = new DefaultMutableTreeNode("Contents");

      root.add(new DefaultMutableTreeNode("1"));
      root.add(new DefaultMutableTreeNode("2"));
      root.add(new DefaultMutableTreeNode("3"));
      root.add(new DefaultMutableTreeNode("4"));

      DefaultTreeModel treeModel = new DefaultTreeModel(root);
      tree = new CheckBoxTree(treeModel);
      tree.setDigIn(true);
      tree.getCheckBoxTreeSelectionModel().setSingleEventMode(true);
      tree.getCheckBoxTreeSelectionModel().addTreeSelectionListener(new TreeSelectionListener() {

         @Override
         public void valueChanged(TreeSelectionEvent event) {
            if (getCheckBoxTree().isCheckBoxEnabled()) {
               Integer row = getRow(event);
               if (row != null) {
                  if (row == 3) {
                     CheckBoxTreeSelectionModel selModel = getCheckBoxTree().getCheckBoxTreeSelectionModel();
                     selModel.addSelectionPath(getCheckBoxTree().getPathForRow(2));
                  }
               }
            }
         }
      });

      add(getCheckBoxTree());
      CheckBoxTreeSelectionModel selModel = getCheckBoxTree().getCheckBoxTreeSelectionModel();
   }

   private Integer getRow(TreeSelectionEvent event) {
      TreePath[] treePaths = event.getPaths();
      if (treePaths.length == 1) {
         TreePath treePath = treePaths[0];
         DefaultMutableTreeNode lastPathComponent = (DefaultMutableTreeNode) treePath.getLastPathComponent();

         if (lastPathComponent.getChildCount() == 0) {
            return getCheckBoxTree().getRowForPath(new TreePath(lastPathComponent.getPath()));
         }
      }
      return null;
   }

   public static void main(String[] args) {
      JDialog dialog = new JDialog((Frame) null, "CheckBoxTreeBug");

      dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
      dialog.getContentPane().add(new CheckBoxTreeSimpleBug());
      dialog.pack();
      dialog.setVisible(true);
   }
}


When I click on "3", checkbox "2" appear clicked, but checkbox "3" no.
I think that the code is ok. I try with and without selModel.setBatchMode(true); selModel.setBatchMode(false); but it doesn't work.
Please can you help me.. When do you think the new version will be released?
fcarballo
 
Posts: 2
Joined: Wed Feb 24, 2010 8:21 am

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Fri Feb 26, 2010 3:08 pm

Thanks for the bug report. We will fix it in both 2.8.5 and 2.9.0 as well. 2.8.5 will be released next week.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Wed Mar 03, 2010 8:35 pm

Just so you know, this is fixed in 2.8.5 just released.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am

Re: CheckBoxTree stack overflow.

Postby JIDE Support » Wed Apr 21, 2010 10:46 am

Just so you know, this is also fixed in 2.9.0 just released.

Thanks,
JIDE Software Technical Support Team
JIDE Support
Site Admin
 
Posts: 37219
Joined: Sun Sep 14, 2003 10:49 am


Return to JIDE Common Layer Open Source Project Discussion (Community Driven)

Who is online

Users browsing this forum: No registered users and 79 guests