Root Handles (icons next to the node) not visible in TreeTable

Hi i am using the example provided at www.java.sun.com for TreeTable. I have a tree table and when i add new nodes the data is visible in the table but the handles are not visible. I don't know how to resolve this problem. Below is my code where i'm adding new data.
private void addNewNode(MyNode _root) {
NodeInfo info = new NodeInfo();
info.order= "Pending";
info.qty = "200";
info.price = "20,000";
MyNode node = new MyNode(info);
_root.add(node);
tree.expandPath(new TreePath(_root.getPath()));

Sorry my mistake...i was not returning TreeTableModel.class in getColumnClass() of my custom treetable model class.

Similar Messages

  • Unable to drag the Icon associated with the node

    I am working on dragging a node from Tree to a list.
    I have to drag the Icon associated with the leaf too. I am able to drag only the string of the node not the Icon that is associated with it. Can you help me with this? I have the code as below. Thanks.
    public class IconNode extends DefaultMutableTreeNode {
    protected Icon icon;
    protected String iconName;
    //* IconNode
    /**Creates an IconNode Object*/
    public IconNode() {
    this(null);
    }//end IconNode
    //* IconNode
    /**Creates an IconNode Object*/
    public IconNode(Object userObject) {
    this(userObject, true, null);
    }// end IconNode
    //* IconNode
    /**Creates an IconNode Object*/
    public IconNode(Object userObject, boolean allowsChildren
              , Icon icon) {
    super(userObject, allowsChildren);
    this.icon = icon;
    }//end IconNode
    //* setIcon
    /**sets the Icon to the node*/
    public void setIcon(Icon icon) {
    this.icon = icon;
    }// end setIcon
    //* getIcon
    /**gets the Icon of the node*/
    public Icon getIcon() {
    return icon;
    }//end getIcon
    //* getIconName
    /**gets the IconName*/
    public String getIconName() {
    if (iconName != null) {
    return iconName;
    } else {
    String str = userObject.toString();
    int index = str.lastIndexOf(".");
    if (index != -1) {
    return str.substring(++index);
    } else {
    return null;
    }//end getIconName
    //* setIconName
    /**sets the IconName*/
    public void setIconName(String name) {
    iconName = name;
    }//end setIconName
    }// end IconNodepublic class IconNode extends DefaultMutableTreeNode {
    protected Icon icon;
    protected String iconName;
    //* IconNode
    /**Creates an IconNode Object*/
    public IconNode() {
    this(null);
    }//end IconNode
    public class DNDTree extends JTree
    public DNDTree (IconNode top)
    super (top);
    DNDTreeHandler dndHandler = new DNDTreeHandler(this);
    setAutoscrolls(true);
    public class DNDTreeHandler extends DnDHandler
    TransferableDataItem transDataItem = new TransferableDataItem();
    public DNDTreeHandler(Component dndComponent)
    super(dndComponent);
    public DataFlavor[] getSupportedDataFlavors()
    return transDataItem.getTransferDataFlavors();
    * Gets the data from the selected object being dragged
    * @return node DataItem being dragged
    public Transferable getTransferable()
    TreePath path = getSelectionPath();
    //DefaultMutableTreeNode selection = (DefaultMutableTreeNode)path.getLastPathComponent();
    IconNode selection = (IconNode)path.getLastPathComponent();
    if (path == null)
    return(null);
    else
    TransferableDataItem node = new TransferableDataItem(selection);
    return(node);
    * Handles the drop of the component after the drag is complete
    * @param transferable Object being dropped
    * @param event drop event information
    public void handleDrop(Transferable transferable, DropTargetDropEvent event) throws Exception
    Point location = event.getLocation();
    //Get path of node where object being dropped
    TreePath path = getClosestPathForLocation(location.x, location.y);
    //No drop target
    if(path == null)
    System.err.println ("Rejected");
    event.rejectDrop();
    else
    Transferable tr = event.getTransferable();
    if(tr.isDataFlavorSupported(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR))
    System.out.println("Got transfered data");
    Object userObject = tr.getTransferData(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR);
    //DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
    IconNode node = (IconNode)path.getLastPathComponent();
    IconNode newNode = new IconNode(userObject);
    DefaultTreeModel model = (DefaultTreeModel)getModel();
    model.insertNodeInto(newNode, node, 0);
    else
    System.err.println ("Rejected");
    event.rejectDrop();
    public abstract class DnDHandler implements DropTargetListener,DragSourceListener, DragGestureListener
    protected DropTarget dropTarget;
    protected DragSource dragSource;
    public DnDHandler(Component dndComponent)
    dropTarget = new DropTarget (dndComponent, this);
    dragSource = new DragSource();
    dragSource.createDefaultDragGestureRecognizer( dndComponent, DnDConstants.ACTION_COPY_OR_MOVE, this);
    //creates transferable based on what's selected or returns null if nothings selected
    protected abstract Transferable getTransferable();
    protected abstract void handleDrop(Transferable transferable, DropTargetDropEvent event) throws Exception;
    protected abstract DataFlavor[] getSupportedDataFlavors();
    public void dropFailed (DragSourceDropEvent event)
    System.out.println("Drop Failed");
    public void dropSuccess (DragSourceDropEvent event)
    System.out.println("Drop was successful");
    private boolean isTransferableSupported(Transferable t)
    DataFlavor[] flavors = getSupportedDataFlavors();
    for (int i=0; i<flavors.length; i++)
    if (t.isDataFlavorSupported(flavors) )
    return true;
    return false;
    public void dragGestureRecognized( DragGestureEvent event)
    Transferable trans = getTransferable();
    Cursor dragIcon = getDragCursor(event);
    if (trans != null)
    // Starts the dragging
    dragSource.startDrag (event, dragIcon, trans, this);
    else
    System.out.println( "nothing was selected");
    * a drop has occurred
    public void drop (DropTargetDropEvent event)
    try
    Transferable transferable = event.getTransferable();
    // we accept only Strings
    if (isTransferableSupported (transferable))
    event.acceptDrop(event.getDropAction());
    handleDrop(transferable, event);
    event.getDropTargetContext().dropComplete(true);
    else
    event.rejectDrop();
    catch (Exception e)
    e.printStackTrace();
    System.err.println( "Drop Exception" + e.getMessage());
    event.rejectDrop();
    //DragSourceListener interfaces
    * is invoked when you are dragging over the DropSite
    public void dragEnter (DropTargetDragEvent event)
    // debug messages for diagnostics
    //System.out.println( "dragEnter");
    int action = event.getDropAction();
    event.acceptDrag (action);
    * is invoked when you are exit the DropSite without dropping
    public void dragExit (DropTargetEvent event)
    //System.out.println( "dragExit");
    * is invoked when a drag operation is going on
    public void dragOver (DropTargetDragEvent event)
    //System.out.println( "dragOver");
    * is invoked if the use modifies the current drop gesture
    public void dropActionChanged ( DropTargetDragEvent event )
    //gets the cursor to start drag
    protected Cursor getDragCursor( DragGestureEvent event)
    if (event.getDragAction() == DnDConstants.ACTION_MOVE)
    return DragSource.DefaultMoveDrop;
    if (event.getDragAction() == DnDConstants.ACTION_COPY_OR_MOVE)
    return DragSource.DefaultCopyDrop;
    else
    return Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
    * this message goes to DragSourceListener, informing it that the dragging
    * has ended
    public void dragDropEnd (DragSourceDropEvent event) {
    if ( event.getDropSuccess())
    dropSuccess(event);
    else
    dropFailed(event);
    * this message goes to DragSourceListener, informing it that the dragging
    * has entered the DropSite
    public void dragEnter (DragSourceDragEvent event)
    //System.out.println( " dragEnter");
    * this message goes to DragSourceListener, informing it that the dragging
    * has exited the DropSite
    public void dragExit (DragSourceEvent event)
    //System.out.println( "dragExit");
    * this message goes to DragSourceListener, informing it that the dragging is currently
    * ocurring over the DropSite
    public void dragOver (DragSourceDragEvent event)
    //System.out.println( "dragExit");
    * is invoked when the user changes the dropAction
    public void dropActionChanged ( DragSourceDragEvent event)
    //System.out.println( "dropActionChanged");
    public class TransferableDataItem extends DefaultMutableTreeNode implements Transferable
    final static int DATA_ITEM = 0;
    final static int STRING = 1;
    final static int PLAIN_TEXT = 2;
    //final public static DataFlavor DEFAULT_MUTABLE_DATAITEM_FLAVOR =
    // new DataFlavor(DefaultMutableTreeNode.class, "Default Mutable Data Item");
    final public static DataFlavor DEFAULT_MUTABLE_DATAITEM_FLAVOR =
    new DataFlavor(IconNode.class, "Default Mutable Data Item");
    static DataFlavor flavors[] = {DEFAULT_MUTABLE_DATAITEM_FLAVOR, DataFlavor.stringFlavor, DataFlavor.plainTextFlavor};
    private Object data;
    public TransferableDataItem()
    public TransferableDataItem(Object data)
    this.data = data;
    public DataFlavor[] getTransferDataFlavors()
    return flavors;
    public Object getTransferData(DataFlavor flavor)
    throws UnsupportedFlavorException, IOException
    Object returnObject;
    if (flavor.equals(flavors[DATA_ITEM]))
    returnObject = data;
    else if (flavor.equals(flavors[STRING]))
    returnObject = data.toString();
    else if (flavor.equals(flavors[PLAIN_TEXT]))
    returnObject = new ByteArrayInputStream(data.toString().getBytes());
    else
    throw new UnsupportedFlavorException(flavor);
    return returnObject;
    public boolean isDataFlavorSupported(DataFlavor flavor)
    boolean returnValue = false;
    for (int i=0, n=flavors.length; i<n; i++) {
    if (flavor.equals(flavors[i]))
    returnValue = true;
    break;
    return returnValue;
    public class DNDList extends JList
    DropTarget dropTarget;
    public DNDList()
    DNDListHandler dndHandler = new DNDListHandler(this);
    setModel(new DefaultListModel());
    //private void addElement(Point location, Object element)
    private void addElement(Point location, IconNode element)
    int index = locationToIndex(location);
    // If index not found, add at end, otherwise add one beyond position
    if (index == -1) {
    index = getModel().getSize();
    else
    index++;
    ((DefaultListModel)getModel()).add(index, element);
    public class DNDListHandler extends DnDHandler
    TransferableDataItem transDataItem = new TransferableDataItem();
    public DNDListHandler(Component dndComponent)
    super(dndComponent);
    public DataFlavor[] getSupportedDataFlavors()
    return transDataItem.getTransferDataFlavors();
    public DataFlavor[] getTransferDataFlavors()
    return transDataItem.getTransferDataFlavors();
    * Gets the data from the selected object being dragged
    * @return node Node being dragged
    public Transferable getTransferable()
    Object selectedItem = getSelectedValue();
    System.out.println("Selected Value is " + selectedItem);
    TransferableDataItem item = new TransferableDataItem(selectedItem);
    return(item);
    * Handles the drop of the component after the drag is complete
    * @param transferable Object being dropped
    * @param event drop event information
    public void handleDrop(Transferable transferable, DropTargetDropEvent event) throws Exception
    Transferable tr = event.getTransferable();
    Point location = event.getLocation();
    if (tr.isDataFlavorSupported(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR))
    //event.acceptDrop (DnDConstants.ACTION_COPY_OR_MOVE);
    // Object userObject = tr.getTransferData(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR);
    IconNode userObject = (IconNode)tr.getTransferData(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR);
    addElement(location, userObject);
    //dropTargetDropEvent.getDropTargetContext().dropComplete(true);
    else
    System.err.println ("Rejected");
    event.rejectDrop();

    I think your problem come from this method :
    if (tr.isDataFlavorSupported(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR))
       System.out.println("Got transfered data");
       Object userObject = tr.getTransferData(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR);
    //DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
       IconNode node = (IconNode)path.getLastPathComponent();
       IconNode newNode = new IconNode(userObject);
       DefaultTreeModel model = (DefaultTreeModel)getModel();
       model.insertNodeInto(newNode, node, 0);
    ...You should write :
    if (tr.isDataFlavorSupported(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR))
       IconNode node = (IconNode)tr.getTransferData(TransferableDataItem.DEFAULT_MUTABLE_DATAITEM_FLAVOR);
       IconNode node = (IconNode)path.getLastPathComponent();
       IconNode newNode = new IconNode(node);
       DefaultTreeModel model = (DefaultTreeModel)getModel();
       model.insertNodeInto(newNode, node, 0);
    ...and create a construcor for IconNode :
    public IconNode(IconNode node) {
       super(node.getUserObject, node.getAllowsChildren());
       icon = node.icon;
    }When you use IconNode newNode = new IconNode(userObject), the icon is null (see your constructor).
    If I can say something, you should simplify your code : you can do the same thing dividing the size of your code by five (at less).
    Denis

  • Ok...so I have the latest version of iTunes...why isn't there a cloud icon next to the movie I just bought?  I assume I need it to download from iCloud.

    Ok...so I have the latest version of iTunes per response to my previous question.  Why isn't there a cloud icon next to the movie I just downloaded?  I assume that's the only way to access movies on the cloud.  ( My computer shows the icon.)

    What are you trying to do? If the movie is on your iPad, the cloud icon will not appear next to the movie. You will see the cloud icon next to the movie if you delete it from your iPad and then you can download it again. That is assuming that the movie is eligible for a free download as not every movie can be downloaded again for free.
    This is a screenshot of the purchased tab in iTunes on my iPad. These movies are already on my iPad so there is no cloud icon next to them for another download.
    What I don't understand is for what reason are you trying to access the movie? If you want to watch the movie, it is in the videos app. Maybe that is where I am missing the boat.

  • Ive installed io7 on my ipad and now itunes (onwindows 8) wont recognise the device (the icon next to the iTune store icon),  have run diagnostics and everything ok.  My ipad asks if the computer is trustwort?hy then it trys to search for photos/videos

    Ive installed io7 on my ipad and now itunes (onwindows 8) wont recognise the device (the icon next to the iTune store icon),  have run diagnostics and everything ok.  My ipad asks if the computer is trustworthy then it trys to search for photos/videos and says none found!  I have done everything....................Help please

    Hello Debbie,
    I would be concerned as well if my iPad was not recognized by iTunes.  Thank you for providing all the information with the steps you took in regards to this issue.  I found an article with a few more steps you can take (you can skip the steps you have already taken):
    iOS: Device not recognized in iTunes for Windows
    http://support.apple.com/kb/TS1538
    Thank you for using Apple Support Communities.
    Best,
    Sheila M.

  • The "J2EE process table" node not visible  in the SAP MMC

    For Netweaver 7.0 - The "J2EE process table" node not visible  in the SAP MMC.
    Details for below
    SAP Systems Manager
    SAP AG
    Version: 7100.109.15.8983
    Window Xp
    Any suggestions would be apperecited.
    Thanks
    Srini

    It's hard to say without seeing the code for TreeTable. But they probably have something like an addNode mothod for the TreeTableNode which will take care of all the updates for you. If you want to do it youself, you will probably have to get the data Model (tree.getModel()???)behind the TreeTable and use one of the fire... methods on it like fireRowChanged(???) or fireTableChanged(???). I would suspect Sun would do it this way.

  • Custom icon NEXT TO the mousec cursor

    I've been pondering on how to make it possible to add a custom icon next to the mouse cursor.
    When the user clicks on a specific component in the gui and starts to "drag" it, an icon should be attached to the mouse cursor that shows that the component is attached to it. Sort of like a tiny icon below the cursor to the right.
    Anyone done this and can share some info?

    You could put a java2d to draw a picture next to the mouse.
    if you made this transparent and on top of everything then that wod work.
    OR
    You could change the mouses image to the icon. But i dont know how you would reposition it.

  • Status Icon next to the battery life.. Little phone with dots...

    Hey,
    What is the little phone icon next to the battery life display on my iphone? I cannot find it in any of the literature..
    A little phone with buttons below it...
    Confused..
    Thanks
    Lucas

    That is TTY
    Settings>Phone>TTY on or off

  • I HAVE A ROUND ICON NEXT TO THE SIGNAL ICON WHAT IS IT

    I HAVE A ROUND ICON NEXT TO THE SIGNAL ICON WHAT IS IT

    iPhone User Guide (For iOS 4.2 and 4.3 Software)

  • New icon next to the battery....never seen it before

    Hi
    I noticed today that my iphone has a new icon next to the battery meter at the top right hand corner of the screen.
    The icon looks like a phone handset with 2 rows of button under it.
    I have looked at all my setting and can't figure out how to make it go away or how it got there.
    Does anyone know what this is or anyone have the same icon?

    TTY
    Settings>Phone>TTY
    TTY, also known as Text Telephone Device or Telecommunication Device for the Deaf (TDD), is a special device required at both ends of the conversation that enables people who are deaf, hard of hearing, or speech-impaired to use the telephone to communicate. TTY works by allowing people to type messages back and forth to one another instead of talking and listening.

  • My hubby's iPhone has a small phone icon next to the battery we don't know what it means

    My hubby's iPhone has a small phone icon next to the battery we don't know what it means

    If you see this symbol in the status bar, it means that TTY is on.  Choose Settings > Phone to turn TTY on or off.

  • In the videos I've seen a thumbnail icon next to the bookmarks icon. Mine is missing. Any idea why or how to get it.

    In the videos on the website I have seen a thumbnail icon next to the bookmarks icon for viewing all your open web pages. Mine is missing.Any idea why or how do I put one on?

    Safari now uses tabs in iOS 5 so that icon is no longer in Safari. You have to tap on the + sign on the right side of the toolbar to create a new tab. You can open a new web site in that tab. You navigate from open page to open page by tapping on the tabs.
    To close a tab - tap on the X in the left side of the tab.

  • Ccidentally deleted the Trash Icon next to the Send/ Reply Icon in Mail and I'm using Lion 10.7.5. Does anyone know how to retrieve it?I accidentally deleted the Trash Icon next to the Send/ Reply Icon in Mail and I'm using Lion 10.7.5. Does anyone k

    I accidentally deleted the Trash Icon next to the Send/ Reply Icon in Mail and I'm using Lion 10.7.5.
    Does anyone know how to retrieve it?

    Luigi
    That worked, I knew it was something simple.
    Mille Grazie!!!
    Michael

  • What does the icon next to the location icon mean? It has a lock with an arrow circling it.

    What does the icon next to the left of thelocation icon mean and to the right of the time? It has a lock with an arrow circling it. Thanks

    It's the portrait orientation lock.  When on, and that icon showing, the screen won't rotate to landscape view when you rotate the phone. 
    To turn it off - double click the home button to show the recently opened apps bar, slide it to the right showing the iPod controls and the Portrait Orientation Lock on the left.

  • I used to have an icon next to the Time Machine icon in Safari that allowed me to sync my devices.  It disappeared and I don't know how to get it back.  Any suggestions?

    I used to have an icon next to the Time Machine icon in Safari that allowed me to sync my devices.  It disappeared and I don't know how to get it back.  Any suggestions?

    Lion no longer has iSync

  • Firefox 14.0.1 is NO longer showing the Norton SAfe Web icon in seacch results. The toolbar is there but NOT the safe web icon next to the URL in search results

    After updating to Firefox 14.0.1 my search results NO longer show the Norton WEB Safe Icon next to each result. It worked fine before the upgrade. The Norton tool bar is there and when you click on the site the safe web report is there but NOT the icon in the search results.

    Norton released updates for Firefox 14 early the same morning as the release of Firefox 14. Norton usually releases updates on the same morning as new Firefox versions. Have you updated Norton through their LiveUpdate?
    *See --> https://community.norton.com/t5/Norton-Toolbar-Norton-Identity/Firefox-14-Support-for-Norton-Toolbar/m-p/760924
    '''If this reply solves your problem, please click "Solved It" next to this reply when <u>signed-in</u> to the forum.'''

Maybe you are looking for