JTree - focusing userObjects (JComponents)

Hi everyone!
I have the following problem and i am despairing:
my JTree has DefaultMutableTreeNodes. Every userObject of a node is a JPanel with a JLabel and a JComponent (normally JTextFields or JComboBoxes).
Now I want to put the focus on the JComponent !!!
it works, by clicking on the JComponent, but not if i go through the tree with the cursor-keys (although the selection is changed to the nodes!)
requestFocusInWindow() does not work, because isDisplayable() of the JComponent returns false!
PEASE HELP !!!
Thanks for any suggestions !

Hi Denis !
I think I haven't configured the editor in the right way !?! Here's more information:
I have a cellRenderer, a cellEditor and a selectionListener.
From the selectionListener I call the startEditing Method:
public void valueChanged(TreeSelectionEvent e) {
      TreePath tp = e.getNewLeadSelectionPath();
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) tp.getLastPathComponent();
      if (node == null)
        return;
      if (MyTreeCellEditor.isCellEditable(node))
     theTree.startEditingAtPath(tp);
}startEditingAtPath throws a NullPointerException if I click on a Node
at javax.swing.plaf.basic.BasicLookAndFeel.compositeRequestFocus(BasicLookAndFeel.java:1748)
and going through the tree with the cursor-keys doesn't work at all !!?!?!?
the cellEditor Method:
public Component getTreeCellEditorComponent(JTree tree, Object value, boolean isSelected,
                                            boolean expanded, boolean leaf, int row) {
      DefaultMutableTreeNode node = (DefaultMutableTreeNode) value;
      Object userObject = node.getUserObject();
      if (userObject instanceof MyPanel)
        return (MyPanel) userObject;
       // else:
      return super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
}Thanks for help !
Andreas

Similar Messages

  • Focusing userObject of a Node

    Hi everyone!
    I have the following problem:
    my JTree has DefaultMutableTreeNodes. Every userObject of a node is a JPanel with a JLabel and a JComponent.
    Now I want to put the focus on the JComponent !!!
    it works, by clicking on the JComponent, but not if i go through the tree with the cursor-keys (although the selection is changed to the nodes!)
    requestFocusInWindow() does not work, because isDisplayable() of the JComponent returns false!
    PEASE HELP !!!
    Thanks for any suggestions !

    Hi,
    May be you need this :
    DECLARE
    htree ITEM;
    parent_node NODE;
    BEGIN
    -- Find the tree itself.
    htree := Find_Item('tree_block.htree3');
    -- Get the parent of the node clicked on.
    parent_node := Ftree.Get_Tree_Node_Parent(htree, :SYSTEM.TRIGGER_NODE);
    ...END;
    And then
    node_value := Ftree.Get_Tree_Node_Property(htree, :SYSTEM.TRIGGER_NODE, Ftree.NODE_VALUE);

  • JTree Focus Problem

    I am useing JTree component in my project Whenever i press the space bar that focus removed from the JTree Node. Please any one can help me.

    tree.getActionMap().put(KeyStroke.getKeyStroke("space bar"),"none");

  • Getting TreePath from DefaultMutableTreeNode

    Hi,
    I am looking through the APIs and I haven't found a way in which I can get the TreePath of a specific DefaultMutableTreeNode. In the class that I am trying to get this value I have the reference to the JTree in which the node is located, and a reference to the node itself.
    Please let me know if there is a way to get this value...
    P.S. I need this value, to set the JTree focus on the node. So, if you have a solution for that as well, without using the TreePath, it would be of great value also.
    Thankx
    Juan

    Well, just in case someone is watching this post...
    I found a way, it may not be the best but here it goes;
    public void setFocus(JTree tree, DefaultMutableTreeNode node) {
         DefaultMutableTreeNode parent= null;
         int nodeLevel= node.getLevel();
         int indx= 0;
         for( int i= 1; i < nodeLevel; i++ ) {
              parent= (DefaultMutableTreeNode)node.getParent();
              indx+= parent.getIndex(node)+1;
              node= parent;
         tree.setSelectionRow(indx);
         tree.requestDefaultFocus();
    }

  • Focusing any JComponent in a JTree

    Hi !
    I have a problem with the focus in my jtree. the problem is, that i have a jcomponent hierarchie as theUserObject of every DefaultMutableTreeNode, which has the following structure:
    abstract MyPanel extends JPanel / (has flowlayout and adds a jlabel)
    MyJComponentPanel extends MyPanel / adds a JComponent to the MyPanel (behind the jlabel)
    now i want to set the focus on the JComponent in 2 ways:
    1. when going through the tree with the cursor-keys (i think the panel gains the focus, but not the component.)
    2. by pressing tab or return and putting the focus on the next jcomponent in such structure
    thanks for any suggestion
    andreas

    No idea anybody on how I could insert JComponents of my own in a JEditorPane ?
    Why the simple Document.insertString () don't work in a JEditorPane if the style is not HTML ?
    Is it possible to tweak JTextPane to make it render HTML (using a Kit) then insert my own styles in it ?
    Thx.
    Matthieu

  • Focus Problem with JTree and Menus

    Hi all,
    I have a problem with focus when editing a JTree and selecting a menu. The problem occurs when the user single clicks on a node, invoking the countdown to edit. If the user quickly clicks on a menu item, the focus will go to the menu item, but then when the countdown finishes, the node now has keyboard focus.
    Below is code to reproduce the problem. Click on the node, hover for a little bit, then quickly click on the menu item.
    How would I go about fixing the problem? Thanks!
    import java.awt.Container;
    import java.awt.GridLayout;
    import javax.swing.JFrame;
    import javax.swing.JMenu;
    import javax.swing.JMenuBar;
    import javax.swing.JMenuItem;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeModel;
    public class MyTree extends JTree {
         public MyTree(DefaultTreeModel treemodel) {
              setModel(treemodel);
              setRootVisible(true);
         public static void main(String[] args) {
              JFrame frame = new JFrame();
              JMenuBar bar = new JMenuBar();
              JMenu menu = new JMenu("Test");
              JMenuItem item = new JMenuItem("Item");
              menu.add(item);
              bar.add(menu);
              frame.setJMenuBar(bar);
              Container contentPane = frame.getContentPane();
              contentPane.setLayout(new GridLayout(1, 2));
              DefaultMutableTreeNode root1 = new DefaultMutableTreeNode("Root");
              root1.add(new DefaultMutableTreeNode("Root2"));
              DefaultTreeModel model = new DefaultTreeModel(root1);
              MyTree tree1 = new MyTree(model);
              tree1.setEditable(true);
              tree1.setCellEditor(
                   new ComponentTreeCellEditor(
                        tree1,
                        new ComponentTreeCellRenderer()));
              tree1.setRowHeight(0);
              contentPane.add(tree1);
              frame.pack();
              frame.show();
    import java.awt.FlowLayout;
    import java.util.EventObject;
    import javax.swing.JLabel;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeCellEditor;
    import javax.swing.tree.TreeCellRenderer;
    public class ComponentTreeCellEditor
         extends DefaultTreeCellEditor
         implements TreeCellEditor {
         private String m_oldValue;
         private TreeCellRenderer m_renderer = null;
         private DefaultTreeModel m_model = null;
         private JPanel m_display = null;
         private JTextField m_field = null;
         private JTree m_tree = null;
         public ComponentTreeCellEditor(
              JTree tree,
              DefaultTreeCellRenderer renderer) {
              super(tree, renderer);
              m_renderer = renderer;
              m_model = (DefaultTreeModel) tree.getModel();
              m_tree = tree;
              m_display = new JPanel(new FlowLayout(FlowLayout.LEFT));
              m_field = new JTextField();
              m_display.add(new JLabel("My Label "));
              m_display.add(m_field);
         public java.awt.Component getTreeCellEditorComponent(
              JTree tree,
              Object value,
              boolean isSelected,
              boolean expanded,
              boolean leaf,
              int row) {
              m_field.setText(value.toString());
              return m_display;
         public Object getCellEditorValue() {
              return m_field.getText();
          * The edited cell should always be selected.
          * @param anEvent the event that fired this function.
          * @return true, always.
         public boolean shouldSelectCell(EventObject anEvent) {
              return true;
          * Only edit immediately if the event is null.
          * @param event the event being studied
          * @return true if event is null, false otherwise.
         protected boolean canEditImmediately(EventObject event) {
              return (event == null);
    }

    You can provide a cell renderer to the JTree to paint the checkBox.
    The following code checks or unchecks the box with each click also:
    _tree.setCellRenderer(new DefaultTreeCellRenderer()
      private JCheckBox checkBox = null;
      public Component getTreeCellRendererComponent(JTree tree,
                                                    Object value,
                                                    boolean selected,
                                                    boolean expanded,
                                                    boolean leaf,
                                                    int row,
                                                    boolean hasFocus)
        // Each node will be drawn as a check box
        if (checkBox == null)
          checkBox  = new JCheckBox();
          checkBox .setBackground(tree.getBackground());
        DefaultMutableTreeNode node = (DefaultMutableTreeNode)value;
        checkBox.setText(node.getUserObject().toString());
        checkBox.setSelected(selected);
        return checkBox;
    });

  • JTree stop cell editing on lost focus and scrollPathToVIsible behavior

    how can you make a Jtree that uses a DefaultTreeCellEditor stop editing when it loses focus to a component other than the
    cell editor's DefaultTextField component ?
    i had to use a custom TreeCellEditor and attach my focus listener to the DefaultTextField object and attach it also to the JTree object
              DefaultTreeCellEditor celEditor = new DefaultTreeCellEditor(containerTree,renderer)
                   @Override
                   public Component getTreeCellEditorComponent(JTree tree, Object value,
                                     boolean isSelected,
                             boolean expanded,
                             boolean leaf, int row) {
                        Component comp = super.getTreeCellEditorComponent(tree, value, isSelected, expanded, leaf, row);
                        boolean found= false;
                        for(FocusListener f:editingComponent.getFocusListeners())
                             if(focusListener.equals(f))
                                  found=true;
                                  break;
                        if(!found)
                             editingComponent.addFocusListener(focusListener);
                        return comp;
    myTree.addFocusListener(focusListener);in JTable there's a property that you switch on/off which does exactly that, is there anything alike for JTree ?
    one more thing,after adding a new TreeNode to the JTree,i'm calling scrollPathToVisible(<path to the new node>),but for all the nodes i add except the first, the user object is not displayed,am i missing something? here's my code
              ActionListener actionListener = new ActionListener(){
                   public void actionPerformed(ActionEvent ae){
                        DefaultTreeModel model = (DefaultTreeModel)containerTree.getModel();
                        int nodeCount=containerTree.getModel().getChildCount(root);
                        if(ae.getSource().equals(menuAdd))
                             DefaultMutableTreeNode newNode=new DefaultMutableTreeNode();
                             if(currentNode>0 && currentNode+1<nodeCount)
                                  model.insertNodeInto(newNode, root, currentNode+1);
                                  newNode.setUserObject("container #"+(currentNode+1));
                             else
                                  model.insertNodeInto(newNode, root, root.getChildCount());
                                  newNode.setUserObject("container #"+nodeCount);
                             TreePath path = new TreePath(newNode.getPath());
                                            // only works properly for 1st node,for the rest i have to
                                            // click on the new node to get the proper display
                             containerTree.scrollPathToVisible(path);
                        else if(nodeCount>=0 && currentNode!=0)
                             model.removeNodeFromParent((DefaultMutableTreeNode)model.getChild(root, currentNode-1));
              };

    i solved the second issue by selecting the new node and starting to edit it

  • Setting a JTree renderer breaks the focus traversal order

    Hello,
    I am not sure what's wrong, but when I set a customize JTree renderer it breaks the focus traversal order of my UI. Can someone tell me what's wrong and also how to prevent it from changing the order of my components?
    For instance, if I have component order 1, 2, 3, 4, 5 to begin with and after I call JTree.setCellRenderer(new SomeRenderer()), the order would change to something like this 1, 2, 4, 5, 3
    To give you an overview of what I am creating, I am customizing a UI that will be plug into JFileChooser to replace the default UI. I know I can create my own FocusTraversalPolicy, but the thing is that I don't know some of my components ahead of time. As long as I can prevent the order change, I think it would be fixed.
    Regards,
    Soot

    Try creating a Short, Self-Contained, Compileable, Executable
    program which has this problem. Right now it would take a
    mind-reader to solve your problem.

  • Disable border for JTree on focus

    Hi,
    How can I disable the border showing on a JTree-Cell when a cell receive the focus?
    I don't want to extends from DefaultTreeCellRenderer.
    Is this a special client property or how can I disable this ( blue ) border ( CrossPlatformLookAndFeel ).
    Regards,
    Olek

    One idea is to use a custom TreeCellRenderer
    http://download.oracle.com/javase/6/docs/api/javax/swing/tree/TreeCellRenderer.htmlWhat I would do is just
    class MyRenderer implements TreeCellRenderer
    }and then take a look at the DefaultTreeCellRenderer source code to see how they implemented.
    Although, I would recommend looking at Apache's implementation instead of Suns (Oracles) since it tends to be much more readable code.
    http://svn.apache.org/repos/asf/harmony/enhanced/archive/classlib/java6/modules/swing/src/main/java/common/javax/swing/tree/DefaultTreeCellRenderer.javaAnd obviously from there you would need to customize the behavior when its selected.
    Hope this helps!
    Brandon

  • How to move focus from one JTree node to another one and then back again?

    Hi all!
    Say I have a very simple JTree
    package main;
    import java.awt.BorderLayout;
    import java.awt.Container;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import javax.swing.JFrame;
    import javax.swing.JScrollPane;
    import javax.swing.JTextField;
    import javax.swing.JTree;
    import javax.swing.event.TreeSelectionEvent;
    import javax.swing.event.TreeSelectionListener;
    import javax.swing.tree.DefaultMutableTreeNode;
    public class SelectableTree extends JFrame implements TreeSelectionListener {
        public static void main(String[] args) {
            new SelectableTree();
        private JTree tree;
        private JTextField currentSelectionField;
        public SelectableTree() {
            super("JTree Selections");
            addWindowListener(new WindowAdapter() {
                public void windowClosing(WindowEvent event) {
                    System.exit(0);
            Container content = getContentPane();
            DefaultMutableTreeNode root = new DefaultMutableTreeNode("Root");
            DefaultMutableTreeNode child;
            DefaultMutableTreeNode grandChild;
            for (int childIndex = 1; childIndex < 4; childIndex++) {
                child = new DefaultMutableTreeNode("Child " + childIndex);
                root.add(child);
                for (int grandChildIndex = 1; grandChildIndex < 4; grandChildIndex++) {
                    grandChild = new DefaultMutableTreeNode("Grandchild "
                            + childIndex + "." + grandChildIndex);
                    child.add(grandChild);
            tree = new JTree(root);
            tree.addTreeSelectionListener(this);
            content.add(new JScrollPane(tree), BorderLayout.CENTER);
            currentSelectionField = new JTextField("Current Selection: NONE");
            content.add(currentSelectionField, BorderLayout.SOUTH);
            setSize(250, 275);
            setVisible(true);
        public void valueChanged(TreeSelectionEvent event) {
            currentSelectionField.setText("Current Selection: "
                    + tree.getLastSelectedPathComponent().toString());
    }All I need is to move focus from currently selected node, to some other node (does not matter which one), then to "sleep" for a second and finally move it back to return selection to the previously selected node. The only question is how do I do this?

    Use a Seperate Thread to do it:
    Runnable r = new Runnable() {
        public void run() {
                   int k=tree.getSelectionRows()[0];
                   DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
                                if(node.getNextSibling()!=null)
                                     tree.setSelectionRow(k+1);
                                else
                                     tree.setSelectionRow(k-1);
                                sleepe(k);
    public void sleepe(int i){
                         try{
                                Thread.sleep(1000);
                                     }catch(Exception e){
                                         e.printStackTrace();
                                  tree.setSelectionRow(i);
        }Then start this thread in a mouse click event(or any other similar),but not in TableSelectionListener because >>if the current selected row is 1 then it will execute the valueChanged method of TableSe..li. and we set the selected row to 2 then again it will execute the valueChanged method of TableSe..li.It will repeat till something,or in error.
    tree.addMouseListener( new MouseListener(){
    public void mouseClicked(MouseEvent e) {
                       new Thread(r).start();
    public  void mouseEntered(MouseEvent e) {
    public  void mouseExited(MouseEvent e) {
    public  void mousePressed(MouseEvent e)     {
    public  void mouseReleased(MouseEvent e) {
      });Note:it worked perfectly for me. So add all the above in the right place and import necessary.It will execute perfectly.

  • Usable JComponents in JTrees?

    Hello,
    I have been looking for a way to put JComponents (e.g., JCheckBoxes, JButtons, etc) into a JTree and have the JComponents still be usable -- I want to be able to select the JCheckBoxes or press the JButtons. I've looked all over the web and the forums with no luck finding anything, and the closest I've come is overriding the TreeCellRenderer like this:
    import java.awt.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.*;
    public class renderer extends JButton
    implements TreeCellRenderer {
    public Component getTreeCellRendererComponent (JTree tree, Object value,
         boolean selected, boolean expanded, boolean leaf, int row,
         boolean hasFocus) {
         String text = value.toString();
         return new JCheckBox(text);
    }but that only returns a drawn JComponent in the tree -- I can't click it or interact with it.
    I would appreciate any help people have; I don't want to have to reinvent the JTree to be able to do this.
    SJ

    In case anyone searches this in the future, I found the answer at:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=2&t=001095
    And the relevant code (copying in case the link goes down):
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.event.*;
    import java.awt.*;
    import javax.swing.event.*;
    import java.util.*;
    public class treedemo1 extends JFrame{
    public treedemo1(){
    super("TreeDemo");
    setSize(500,500);
    JPanel p=new JPanel();
    p.setLayout(new BorderLayout());
    JCheckBox theParent = new JCheckBox("Feature Set #1");
    JCheckBox thefeature = new JCheckBox("First Feature");
    JCheckBox feature2=new JCheckBox("Second Feature");
    JCheckBox feature3=new JCheckBox("Third Feature");
    DefaultMutableTreeNode top = new DefaultMutableTreeNode(theParent,true);
    DefaultMutableTreeNode n1=new DefaultMutableTreeNode(thefeature,true);
    DefaultMutableTreeNode n2=new DefaultMutableTreeNode(feature2,true);
    DefaultMutableTreeNode n3=new DefaultMutableTreeNode(feature3,false);
    n1.add(n3);
    top.add(n1);
    top.add(n2);
    JTree tree=new JTree(top);
    p.add(tree,BorderLayout.NORTH);
    getContentPane().add(p);
    TestRenderer tr = new TestRenderer();
    TestEditor1 te = new TestEditor1();
    tree.setEditable(true);
    tree.setCellRenderer(tr);
    tree.setCellEditor(te);
    public class TestEditor1 implements TreeCellEditor
    public TestEditor1()
    public void addCellEditorListener(CellEditorListener l)
    public void cancelCellEditing()
    public Object getCellEditorValue()
    return this;
    public boolean isCellEditable(EventObject evt)
    if (evt instanceof MouseEvent)
    MouseEvent mevt = (MouseEvent) evt;
    if (mevt.getClickCount() == 1)
    return true;
    return false;
    public void removeCellEditorListener(CellEditorListener l)
    public boolean shouldSelectCell(EventObject anEvent)
    return true;
    public boolean stopCellEditing()
    return false;
    public Component getTreeCellEditorComponent(JTree tree,
    Object value,
    boolean isSelected,
    boolean expanded,
    boolean leaf,
    int row)
    DefaultMutableTreeNode temp = (DefaultMutableTreeNode) value;
    JCheckBox temp2=(JCheckBox)temp.getUserObject();
    return temp2;
    public class TestRenderer implements TreeCellRenderer
    transient protected Icon closedIcon;
    transient protected Icon openIcon;
    public TestRenderer()
    public Component getTreeCellRendererComponent(JTree tree,
    Object value,
    boolean selected,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus)
    DefaultMutableTreeNode temp = (DefaultMutableTreeNode) value;
    JCheckBox temp2=(JCheckBox)temp.getUserObject();
    temp2.setBackground(UIManager.getColor("Tree.textBackground"));
    return temp2;
    public void setClosedIcon(Icon newIcon)
    closedIcon = newIcon;
    public void setOpenIcon(Icon newIcon)
    openIcon = newIcon;
    public static void main(String args[]){
    JFrame frame = new treedemo1();
    frame.addWindowListener(new WindowAdapter()
    public void windowClosing(WindowEvent e)
    System.exit(0);
    frame.pack();
    frame.setVisible(true);
    }SJ

  • JTree - userobject

    Hello,
    - JTree consists of nodes.
    - Each node has its own userObject.
    - An userObject contains node specific information, like node-name etc.
    Is there also a userObject for the JTree it self?
    I have 2 Classes.
    Class 1: Creates JTree
    Class 2: Access to Class 1 and get JTree
    If I create the JTree, I want just to set a flag (true/false).
    If I get the JTree, I want to read this flag from the JTree-object.
    How do I do this, any hint?
    -many thanks
    Aykut

    I mean is there any possibility to pass data (in my
    case just a flag) with JTree?
    class FlaggedTree extends JTree {
      private boolean flag;
      // .. getters & setters for flag
    }

  • JTree problem: cannot parse UserObject

    Hi,
    i have a JTree and added a TreeSelectionListener on it.
    At first i get the UserObject and save it as an Object. Then i want to check what class it is and react correct.
    i know that it must be an Instance of Element, but my program thinks that it is no instance of it.
    here�s my code
    ... //newNode is the currently selected node
    //get userObject
    Object userObject = newNode.getUserObject();
    //that is the way i�ve tried first but it doesn�t work
    if(userObject instanceof Comment)
      doSomething((Comment) userObject);
    else if(userObject instanceof Element)
      doSomethingElse((Element) userObject);
    else
      doNothing();
    //now the way i�ve tried it again
    //that doesn�t work too
    boolean typeFound = false;
    try{ doSomething((Comment) userObject); done = true; }
    catch(ClassCastException cce) {;}
    if(!done)
      try{ doSomethingElse((Element) userObject); done = true; }
      catch(ClassCastException cce) {;}
    if(!done)
      doNothing();
    //but when i do this i get the correct output
    //for example "Comment: text" or something, that tells me that
    //it is a comment
    System.out.println(userObject);
    ...any ideas why it doesn�t work?
    thx anyway
    cu Errraddicator

    (Sorry previous post was badly formatted!)
    Is your Element class inheriting from Comment ?
    If it is the case, you'll have to invert the tests order... when testing instances of a hierarchy of classes, you have to begin by the lower one.
    For example:
    java.lang.Object
      |
      +--java.awt.Component  is instance of Object / Component
          |
          +--java.awt.Button is instance of Object / Component / Button
          |
          +--java.awt.Canvas is instance of Object / Component / Canvas
          : ... etc.If you wanted to distinguish a Button from a Component, the test would be:
          if (myObject instanceof Button) {
             // Stuff for buttons here...
          else if (myObject instanceof Component) {
             // Stuff for other components here...
          }Regards.

  • Can we add JComponents as nodes to JTree

    Hi:
    can we add some components to JTree. Say for example Can I show buttons as JTree Nodes?

    You can add anything to a tree or list component. You have to provide your own TreeCellRenderer (extend DefaultTreeCellRenderer and look up some examples on the web), or ListCellRenderer. To allow inline editing of data, you provide a DefaultTreeCellEditor derived implementation. Set these on the tree, and each will handle the rendering and/or editing of nodes. As far as I know, you would only have one renderer, but you can chain them if in your constructor you provide a parameter of TreeCellRenderer, OR you can call upon super.xxx() to use the super class your class extends. Ideally one renderer and one editor is all you need. You just have to write code in the getCellRenderer() and getCellEditor() methods (forget if that is their name off the top of my head..but look att TreeCellRenderer interface and TreeCellEditor interface for the method you must implement).
    When you provide a cell editor, you can actually return a JPanel component, and put all kinds of components in that panel. Set the tree row height size to 0, and when a node goes into edit mode, it calls upon your cell editor to make sure it can be edited (and the tree setEditable(true) must have been called), and you can actually "grow" the node inline to whatever size for the editor. Once editing is done, it goes back to the renderer to draw the node again, so that you may show a normal sized node.

  • 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.

Maybe you are looking for

  • Unable to Load Mac OS Mountain Lion On new Hard Drive

    So recently my internal Hard Drive in my Mid 2012 Mac book Pro has stopped functioning, so i made a trip to best by to get a new one. But once i boot from the  my Mountain Lion Disk and select Disk Utility I am unable to format my drive to Mac OS Ext

  • Mouse state with menu items overlapping control

    Hi, I have an issue with retrieving the mouse location using GetGraphCoordsFromPoint... I am using the return status of GetGraphCoordsFromPoint to determine if the mouse cursor is above the plot area of my graph control (1) or not (0) in order to swi

  • PNP program error

    I am getting compilation error "DFIES has already been declared" when I use the program below (with logical DB PNP) REPORT  ZHR2. include DBPNPCOM. INITIALIZATION. rp-sel-ein-aus-init. start-of-selection. any idea what's wrong?  I am trying to write

  • Event booking statuses

    Is there any way to amend or add event booking statuses? At the moment the default status is "success" can I replace this with something like "booking confirmed" then add "invoice sent" and "payment received"? Thanks for any help.

  • Usb 2 pci card - not working!

    I have a G4 400 MHz with Memory of 1.12 GB and a Bus Speed of 100 MHz. I recently added a hard drive without problem, and a pci card. This pci card states on the box "compatable with mac osx". However, I have bought an EYE TV stick (for digital chann