expanding TreeComboBox

This forum is used by users to request and discuss new product features. Please do not use this forum for technical support including bug reports.

Moderator: JIDE Support

Forum rules
Product suggestions only. Please do not use this forum for technical support including bug reports.

expanding TreeComboBox

Postby nicola.gioia » Mon Dec 05, 2005 10:25 am

when I exec a setSelectedItem(Object e) on a TreeComboBox
the combo box will always expand. It is possible to select a level in a tree in the TreeComboBox without expand the combobox?
Thanks
nicola.gioia
 
Posts: 60
Joined: Tue Sep 20, 2005 6:57 am

Postby JIDE Support » Mon Dec 05, 2005 11:29 am

I wonder why I can't reproduce it in ComboBoxDemo. Are you on latest jide 1.8.5.02?

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

Postby nicola.gioia » Tue Dec 06, 2005 5:07 am

I have found the problem:
i need to override the method setSelectedItem(Object e) that in his body call the method this.getTree() which cause the showing of the popup
The code example needed to reproduce the problem is:
Code: Select all
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.tree.DefaultMutableTreeNode;

import com.jidesoft.combobox.TreeComboBox;

public class TreeComboExample extends JFrame{
   protected TreeComboBox tcb;
   JTree tree;
   public TreeComboExample() {
      init();
   }
   protected void init() {
      this.setContentPane(new JPanel(new BorderLayout()));
      this.setSize(new Dimension(150,60));
      this.setDefaultCloseOperation(JDialog.EXIT_ON_CLOSE);
      
      tree = new JTree();
      this.tcb = new TreeComboBox(tree.getModel());
      this.getContentPane().add(this.tcb,BorderLayout.CENTER);
      
      JButton b = new JButton("select");
      b.addActionListener(new ActionListener() {
         public void actionPerformed(ActionEvent e) {
            tcb.setSelectedItem(tree.getModel().getChild(((DefaultMutableTreeNode)tree.getModel().getRoot()).getChildAt(2),2));
            tcb.getTree();
         }});
      this.getContentPane().add(b,BorderLayout.WEST);
   }
}


In this code I have inserted the getTree() in action of button instead that in the overrided method, but the effect is the same.
my version of JIde is 1.8.5 but i don't know which build.
nicola.gioia
 
Posts: 60
Joined: Tue Sep 20, 2005 6:57 am

Postby JIDE Support » Tue Dec 06, 2005 9:21 am

getTree() will show the popup. The reason is the tree is not created until popup is shown. Since you ask for the tree, we have to show popup first then return you the tree instance.

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


Return to Product Suggestions

Who is online

Users browsing this forum: No registered users and 102 guests