Drop on a Tree Node - Help!

On a drop on a tree node, I'd like to get the item that is
being dropped on.
Tree object being dropped on: event.currentTarget
Index of node in tree being dropped on:
event.currentTarget..calculateDropIndex(event); where event is the
DragEvent
dropTarget is a great name for a method that would do this,
but it returns a display object.
Some ideas:
1. Use the index to somehow go through the XML data provider.
I don't think this is the right way - the XML structure is not list
based.
2. The Tree creates a list from the XML. How can I leverage
that and get the item for a given node index? dropTarget seems like
the right term, but it returns a display object.
3. tree.selectedItem and tree.Selected Items return null and
an array of null, so I can't use that either.

Hello Brian,
thanks for your reply.
The benefit of focusing a node in the tree is the following:
If a person only uses the keyboard to navigate (e.g. because of him/her being blind) expands a tree node, he expects the focus still being on the expanded tree node afterwards. But if a roundtrip to the server happens (because of a executed onClick-event) the focus after the reload is at the beginning of the page again. Thus the blind person hast to TAB through the whole page again until he reaches the tree node he has expanded.
I use the com.sapportals.htmlb.* package for the htmlb-elements.
Almost all elements are underclasses of com.sapportals.htmlb.Component, but Treenode is not.
I use a model to create tree nodes. TreeNodes are created like this in the Model:
  mComponentsNode = new TreeNode(COMP_NODE_ID);
  mComponentsNode.setComponent(new TextView(COMP_NODE_TEXT));
  mComponentsNode.setOnNodeClick(MODE_ON_CLICK_EVENT);
  mComponentsNode.setOnNodeExpand(TREE_NODE_EXPAND_EVENT);
  mComponentsNode.setOnNodeClose(TREE_NODE_CLOSE_EVENT);
  mComponentsNode.setTooltip(COMP_NODE_TOOLTIP);
  mComponentsNode.setOpen(true);
  mHomeNode.addChildNode(mComponentsNode);
In the JSP the tree is created like this:
  <hbj:tree id="configTree"
    title=""
    rootNode="configTree"
    rootNodeIsVisible="false">
  </tree>
Do you have any idea?
Thanks!
Regards,
Bastian

Similar Messages

  • Hierachical Tree node(help me please)

    Hi experts,
    JDEV 11.1.2.0.0
    i hav 3 tables say category_1 ,category_2(FK - cat1_code), & category_3( FK - cat1_code&cat2_code)......
    I created a BC from these tables and also created a view link from category_1 to category_2 & another view link from category_2 to category_3....
    then i made a hirearchical tree stucture to display database items....i converted all node to a Command link....
    My usecase is follows.......
    when i click each hierarchical link(data fetched from table) it should navigate to its master form for creating a new master a record.....means , if i clicked a category_1 data , it should navigate to category_1 master form to create a new record.....
    I almost done for my use case.....but i dnt knw how we can get corresponding iterator binds from tree definition ......this my page data binding definition
    <?xml version="1.0" encoding="UTF-8" ?>
    <pageDefinition xmlns="http://xmlns.oracle.com/adfm/uimodel" version="11.1.2.60.17" id="categoryPageDef"
    Package="pages">
    <parameters/>
    <executables>
    <variableIterator id="variables"/>
    *<iterator Binds="Iascat1View1" RangeSize="25" DataControl="AppModuleDataControl" id="Iascat1View1Iterator"/>*
    *<iterator id="Iascat2View1Iterator" Binds="Iascat2View1" DataControl="AppModuleDataControl" RangeSize="25"/>*
    *<iterator id="Iascat3View1Iterator" Binds="Iascat3View1" DataControl="AppModuleDataControl" RangeSize="25"/>* </executables>
    <bindings>
    *<tree IterBinding="Iascat1View1Iterator" id="Iascat1View1">*
    *<nodeDefinition DefName="inv.EntityVO.Iascat1View" Name="Iascat1View10"*
    *TargetIterator="${bindings.Iascat1View1Iterator}">*
    <AttrNames>
    <Item Value="Cat1Code"/>
    <Item Value="Cat1Name"/>
    </AttrNames>
    <Accessors>
    <Item Value="Iascat2View"/>
    </Accessors>
    </nodeDefinition>
    *<nodeDefinition DefName="inv.EntityVO.Iascat2View" Name="Iascat1View11"*
    *TargetIterator="${bindings.Iascat2View1Iterator}">*
    <AttrNames>
    <Item Value="Cat2Code"/>
    <Item Value="Cat2Name"/>
    </AttrNames>
    <Accessors>
    <Item Value="Iascat3View"/>
    </Accessors>
    </nodeDefinition>
    *<nodeDefinition DefName="inv.EntityVO.Iascat3View" Name="Iascat1View12"*
    *TargetIterator="${bindings.Iascat3View1Iterator}">*
    <AttrNames>
    <Item Value="Cat3Code"/>
    <Item Value="Cat3Name"/>
    </AttrNames>
    </nodeDefinition>
    </tree>
    </bindings>
    </pageDefinition>
    *how can i achieve this? OR*
    *Suggest any Other Way?*
    PMS
    Edited by: pms on Jan 30, 2012 3:49 PM
    Edited by: pms on Jan 30, 2012 4:07 PM
    Edited by: pms on Jan 30, 2012 4:13 PM
    Edited by: pms on Jan 30, 2012 4:49 PM
    Edited by: pms on Jan 30, 2012 4:58 PM

    Hi john,
    Im sorry , if i did against rules of the forum....
    Actually i stucked on my work , thats why i did like this to get response from forum members.....
    PMS

  • Tree node to respond to the drag and drop...

    I have to be able to drag a file into a tree node to drop.
    When I drop at the tree node, the file should be shown at the right side of panel. Just like MS Window Explorer.
    Drag and drop at the table to table is working but not drag into the tree and automatically moves into the tree... is...
    Any idea would be welcomded.

    You'll need to setDragEnabled and write a TransferHandler for the JTree. See Introduction to Drag and Drop and Data Transfer.

  • Drop on tree node

    hi
    i want to enable drag 'n' drop for a tree. it works mostly as expected, but it it is not possible to drop a node on another node which has no children. to make this possible, i had to set has_children to true for every node, even if the node has no children. this makes the expander showing up, which is quiet ugly.
    is there another way to drop on a node without any children (like in sapgui tree)?
    thx

    hi,
    If you described situation is right, i do think that you can modify the Context Node of Tree dynamically.
    How to do it?
    You know, the tree node has one property named "has children". So, i think you can add one attribute to your context node, and bind it with this property.
    Then, you can use your Drag&Drop event, in  which you can get so many parameters,such as  'ID','INDEX','Offset' ,etc. And i think you can make use of these parameters to get the the context element if necessary.
    Then, you can set the context attribute of your drop-target tree node's element dynamically.
    At the same time, i think you need clear the Drag-source tree node's "Has children" attribute if necessary.
    I don't know whether it can work fine, i just wrote what i thought out about your post.You can check, hope it can help you a little a little.
    Best wishes.

  • Help needed in drag and drop of Flex tree

    Hi,
    We have an application which allows drag and drop between
    multiple
    trees and lists.
    Here are the steps I follow to refresh on drag and drop:
    1. Dispatch a custom event which calls server.
    2. On successful response from server I change the model
    which is
    data provider for the tree.
    3. Then, set a flag which triggers 'invalidateDisplayList'
    and 'invalidateList' for tree (and other listeners).
    4. The tree refreshes fine. But as soon as I drag and drop
    between
    trees again, I get this error in Tree.as:
    TypeError: Error #1010: A term is undefined and has no
    properties.
    at mx.controls::Tree/::updateDropData()
    at mx.controls::Tree/calculateDropIndex()
    at mx.controls.listClasses::ListBase/showDropFeedback()
    at mx.controls::Tree/showDropFeedback()
    The behaviour is weird, sometimes the browser hangs and stops
    responding.
    I am calling 'contentTree.showDropFeedback(event)' in my
    dragOver
    event listener which is triggering error.
    My tree data provider is a custom class which has 'children'
    array
    collection attribute.
    Any help on how to resolve this issue would be highly
    appreciated.
    Thanks in advance,
    Sujatha

    the major restrictions in its implemented only in
    jdk1.1.Why!

  • Help with building a JTree using tree node and node renderers

    Hi,
    I am having a few problems with JTree's. basically I want to build JTree from a web spider. The webspide searches a website checking links and stores the current url that is being processed as a string in the variable msg. I wan to use this variable to build a JTree in a new class and then add it to my GUI. I have created a tree node class and a renderer node class, these classes are built fine. can someone point me in the direction for actually using these to build my tree in a seperate class and then displaying it in a GUI class?
    *nodeRenderer.java
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.awt.*;
    import java.net.*;
    public class nodeRenderer extends DefaultTreeCellRenderer
                                       implements TreeCellRenderer
    public static Icon icon= null;
    public nodeRenderer() {
    icon = new ImageIcon(getClass().getResource("icon.gif"));
    public Component getTreeCellRendererComponent(
    JTree tree,
    Object value,
    boolean sel,
    boolean expanded,
    boolean leaf,
    int row,
    boolean hasFocus) {
    super.getTreeCellRendererComponent(
    tree, value, sel,
    expanded, leaf, row,
    hasFocus);
    treeNode node = (treeNode)(((DefaultMutableTreeNode)value).getUserObject());
    if(icon != null) // set a custom icon
    setOpenIcon(icon);
    setClosedIcon(icon);
    setLeafIcon(icon);
         return this;
    *treeNode.java
    *this is the class to represent a node
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.util.*;
    import java.net.*;
    * Class used to hold information about a web site that has
    * been searched by the spider class
    public class treeNode
    *Url from the WebSpiderController Class
    *that is currently being processed
    public String msg;
    treeNode(String urlText)
         msg = urlText;
    String getUrlText()
         return msg;
    //gui.java
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class gui extends JFrame implements Runnable
         *declare variable, boolean
         *thread, a object and a center
         *pane
         protected URL urlInput;
         protected Thread bgThread;
         protected boolean run = false;
         protected WebSpider webSpider;
         public gui()
              *create the gui here
              setTitle("Testing Tool");
         setSize(600,600);
         //add Buttons to the tool bar
         start.setText("Start");
         start.setActionCommand("Start");
         toolBar.add(start);
         ButtonListener startListener = new ButtonListener();
              start.addActionListener(startListener);
              cancel.setText("Cancel");
         cancel.setActionCommand("Cancel");
         toolBar.add(cancel);
         ButtonListener cancelListener = new ButtonListener();
              cancel.addActionListener(cancelListener);
              close.setText("Close");
         close.setActionCommand("Close");
         toolBar.add(close);
         ButtonListener closeListener = new ButtonListener();
              close.addActionListener(closeListener);
              //creat a simple form
              urlLabel.setText("Enter URL:");
              urlLabel.setBounds(100,36,288,24);
              formTab.add(urlLabel);
              url.setBounds(170,36,288,24);
              formTab.add(url);
              current.setText("Currently Processing: ");
              current.setBounds(100,80,288,24);
              formTab.add(current);
         //add scroll bars to the error messages screen and website structure
         errorPane.setAutoscrolls(true);
         errorPane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         errorPane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         errorPane.setOpaque(true);
         errorTab.add(errorPane);
         errorPane.setBounds(0,0,580,490);
         errorText.setEditable(false);
         errorPane.getViewport().add(errorText);
         errorText.setBounds(0,0,600,550);
         treePane.setAutoscrolls(true);
         treePane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         treePane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         treePane.setOpaque(true);
         treeTab.add(treePane);
         treePane.setBounds(0,0,580,490);
         treeText.setEditable(false);
         treePane.getViewport().add(treeText);
         treeText.setBounds(0,0,600,550);
         //create the tabbed window           
    centerPane.setBorder(new javax.swing.border.EtchedBorder());
    formTab.setLayout(null);
    errorTab.setLayout(null);
    treeTab.setLayout(null);
    centerPane.addTab("Search Parameters", formTab);
    centerPane.addTab("Error Messages", errorTab);
    centerPane.addTab("Website Structure", treeTab);
              //add the tool bar and tabbed pane
              getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
    getContentPane().add(centerPane, java.awt.BorderLayout.CENTER);                    
              *create the tool bar pane, a center pane, add the buttons,
              *labels, tabs, a text field for user input here
              javax.swing.JPanel toolBar = new javax.swing.JPanel();
              javax.swing.JButton start = new javax.swing.JButton();
              javax.swing.JButton cancel = new javax.swing.JButton();
              javax.swing.JButton close = new javax.swing.JButton();      
              javax.swing.JTabbedPane centerPane = new javax.swing.JTabbedPane();
              javax.swing.JPanel formTab = new javax.swing.JPanel();
              javax.swing.JLabel urlLabel = new javax.swing.JLabel();
              javax.swing.JLabel current = new javax.swing.JLabel();
              javax.swing.JTextField url = new javax.swing.JTextField();
              javax.swing.JPanel errorTab = new javax.swing.JPanel();
              javax.swing.JTextArea errorText = new javax.swing.JTextArea();
              javax.swing.JScrollPane errorPane = new javax.swing.JScrollPane();
              javax.swing.JPanel treeTab = new javax.swing.JPanel();
              javax.swing.JTextArea treeText = new javax.swing.JTextArea();
              javax.swing.JScrollPane treePane = new javax.swing.JScrollPane();
              javax.swing.JTree searchTree = new javax.swing.JTree();
              *show the gui
              public static void main(String args[])
              (new gui()).setVisible(true);
         *listen for the button presses and set the
         *boolean flag depending on which button is pressed
         class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   Object object = event.getSource();
                   if (object == start)
                        run = true;
                        startActionPerformed(event);
                   if (object == cancel)
                        run = false;
                        startActionPerformed(event);
                   if (object == close)
                        System.exit(0);
         *this method is called when the start or
         *cancel button is pressed.
         void startActionPerformed (ActionEvent event)
              if (run == true && bgThread == null)
                   bgThread = new Thread(this);
                   bgThread.start();
              if (run == false && bgThread != null)
                   webSpider.cancel();
         *this mehtod will start the background thred.
         *the background thread is required so that the
         *GUI is still displayed
         public void run()
              try
                   webSpider = new WebSpider(this);
                   webSpider.clear();
                   urlInput = new URL(url.getText());
                   webSpider.addURL(urlInput);
                   webSpider.run();
                   bgThread=null;
              catch (MalformedURLException e)
                   addressError addErr = new addressError();
                   addErr.addMsg = "URL ERROR - PLEASE CHECK";
                   SwingUtilities.invokeLater(addErr);
              *this method is called by the web spider
              *once a url is found. Validation of navigation
              *happens here.
              public boolean urlFound(URL urlInput,URL url)
                   CurrentlyProcessing pro = new CurrentlyProcessing();
              pro.msg = url.toString();
              SwingUtilities.invokeLater(pro);
              if (!testLink(url))
                        navigationError navErr = new navigationError();
                        navErr.navMsg = "Broken Link "+url+" caused on "+urlInput+"\n";
                        return false;
              if (!url.getHost().equalsIgnoreCase(urlInput.getHost()))
                   return false;
              else
                   return true;
              *this method is called internally to check
         *that a link works
              protected boolean testLink(URL url)
              try
                   URLConnection connection = url.openConnection();
                   connection.connect();
                   return true;
              catch (IOException e)
                   return false;
         *this method is called when an error is
         *found.
              public void URLError(URL url)
              *this method is called when an email
              *address is found
              public void emailFound(String email)
              /*this method will update any errors found inc
              *address errors and broken links
              class addressError implements Runnable
                   public String addMsg;
                   public void run()
                        errorText.append(addMsg);
                        current.setText("Currently Processing: "+ addMsg);
              class navigationError implements Runnable
                   public String navMsg;
                   public void run()
                        errorText.append(navMsg);
              *this method will update the currently
              *processing field on the GUI
              class CurrentlyProcessing implements Runnable
              public String msg;
              public void run()
                   current.setText("Currently Processing: " + msg );
    //webspider.java
    import java.util.*;
    import java.net.*;
    import java.io.*;
    import javax.swing.text.*;
    import javax.swing.text.html.*;
    import javax.swing.tree.*;
    import javax.swing.*;
    *this class implements the spider.
    public class WebSpider extends HTMLEditorKit
         *make a collection of the URL's
         protected Collection urlErrors = new ArrayList(3);
         protected Collection urlsWaiting = new ArrayList(3);
         protected Collection urlsProcessed = new ArrayList(3);
         //report URL's to this class
         protected gui report;
         *this flag will indicate whether the process
         *is to be cancelled
         protected boolean cancel = false;
         *The constructor
         *report the urls to the wui class
         public WebSpider(gui report)
         this.report = report;
         *get the urls from the above declared
         *collections
         public Collection getUrlErrors()
         return urlErrors;
         public Collection getUrlsWaiting()
         return urlsWaiting;
         public Collection getUrlsProcessed()
         return urlsProcessed;
         * Clear all of the collections.
         public void clear()
         getUrlErrors().clear();
         getUrlsWaiting().clear();
         getUrlsProcessed().clear();
         *Set a flag that will cause the begin
         *method to return before it is done.
         public void cancel()
         cancel = true;
         *add the entered url for porcessing
         public void addURL(URL url)
         if (getUrlsWaiting().contains(url))
              return;
         if (getUrlErrors().contains(url))
              return;
         if (getUrlsProcessed().contains(url))
              return;
         /*WRITE TO LOG FILE*/
         log("Adding to workload: " + url );
         getUrlsWaiting().add(url);
         *process a url
         public void processURL(URL url)
         try
              /*WRITE TO LOGFILE*/
              log("Processing: " + url );
              // get the URL's contents
              URLConnection connection = url.openConnection();
              if ((connection.getContentType()!=null) &&
         !connection.getContentType().toLowerCase().startsWith("text/"))
              getUrlsWaiting().remove(url);
              getUrlsProcessed().add(url);
              log("Not processing because content type is: " +
         connection.getContentType() );
                   return;
         // read the URL
         InputStream is = connection.getInputStream();
         Reader r = new InputStreamReader(is);
         // parse the URL
         HTMLEditorKit.Parser parse = new HTMLParse().getParser();
         parse.parse(r,new Parser(url),true);
    catch (IOException e)
         getUrlsWaiting().remove(url);
         getUrlErrors().add(url);
         log("Error: " + url );
         report.URLError(url);
         return;
    // mark URL as complete
    getUrlsWaiting().remove(url);
    getUrlsProcessed().add(url);
    log("Complete: " + url );
    *start the spider
    public void run()
    cancel = false;
    while (!getUrlsWaiting().isEmpty() && !cancel)
         Object list[] = getUrlsWaiting().toArray();
         for (int i=0;(i<list.length)&&!cancel;i++)
         processURL((URL)list);
    * A HTML parser callback used by this class to detect links
    protected class Parser extends HTMLEditorKit.ParserCallback
    protected URL urlInput;
    public Parser(URL urlInput)
    this.urlInput = urlInput;
    public void handleSimpleTag(HTML.Tag t,MutableAttributeSet a,int pos)
    String href = (String)a.getAttribute(HTML.Attribute.HREF);
    if((href==null) && (t==HTML.Tag.FRAME))
    href = (String)a.getAttribute(HTML.Attribute.SRC);
    if (href==null)
    return;
    int i = href.indexOf('#');
    if (i!=-1)
    href = href.substring(0,i);
    if (href.toLowerCase().startsWith("mailto:"))
    report.emailFound(href);
    return;
    handleLink(urlInput,href);
    public void handleStartTag(HTML.Tag t,MutableAttributeSet a,int pos)
    handleSimpleTag(t,a,pos); // handle the same way
    protected void handleLink(URL urlInput,String str)
    try
         URL url = new URL(urlInput,str);
    if (report.urlFound(urlInput,url))
    addURL(url);
    catch (MalformedURLException e)
    log("Found malformed URL: " + str);
    *log the information of the spider
    public void log(String entry)
    System.out.println( (new Date()) + ":" + entry );
    I have a seperate class for parseing the HTML. Any help would be greatly appreciated
    mrv

    Hi Sorry to be a pain again,
    I have re worked the gui class so it looks like this now:
    import java.awt.*;
    import java.awt.event.*;
    import javax.swing.*;
    import javax.swing.tree.*;
    import javax.swing.event.*;
    import java.net.*;
    import java.io.*;
    import java.util.*;
    public class gui extends JFrame implements Runnable
         *declare variable, boolean
         *thread, a object and a center
         *pane
         protected URL urlInput;
         protected Thread bgThread;
         protected boolean run = false;
         protected WebSpider webSpider;
         public String msgInfo;
         public String brokenUrl;
         public String goodUrl;
         public String deadUrl;
         protected DefaultMutableTreeNode rootNode;
    protected DefaultTreeModel treeModel;
         public gui()
              *create the gui here
              setTitle("Testing Tool");
         setSize(600,600);
         //add Buttons to the tool bar
         start.setText("Start");
         start.setActionCommand("Start");
         toolBar.add(start);
         ButtonListener startListener = new ButtonListener();
              start.addActionListener(startListener);
              cancel.setText("Cancel");
         cancel.setActionCommand("Cancel");
         toolBar.add(cancel);
         ButtonListener cancelListener = new ButtonListener();
              cancel.addActionListener(cancelListener);
              close.setText("Close");
         close.setActionCommand("Close");
         toolBar.add(close);
         ButtonListener closeListener = new ButtonListener();
              close.addActionListener(closeListener);
              //creat a simple form
              urlLabel.setText("Enter URL:");
              urlLabel.setBounds(100,36,288,24);
              formTab.add(urlLabel);
              url.setBounds(170,36,288,24);
              formTab.add(url);
              current.setText("Currently Processing: ");
              current.setBounds(100,80,288,24);
              formTab.add(current);
         //add scroll bars to the error messages screen and website structure
         errorPane.setAutoscrolls(true);
         errorPane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         errorPane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         errorPane.setOpaque(true);
         errorTab.add(errorPane);
         errorPane.setBounds(0,0,580,490);
         errorText.setEditable(false);
         errorPane.getViewport().add(errorText);
         errorText.setBounds(0,0,600,550);
         treePane.setAutoscrolls(true);
         treePane.setHorizontalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
         treePane.setVerticalScrollBarPolicy(javax.swing.
         ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
         treePane.setOpaque(true);
         treeTab.add(treePane);
         treePane.setBounds(0,0,580,490);
         treeText.setEditable(false);
         treePane.getViewport().add(treeText);
         treeText.setBounds(0,0,600,550);
         //JTree
         // NEW CODE
         rootNode = new DefaultMutableTreeNode("Root Node");
         treeModel = new DefaultTreeModel(rootNode);
         treeModel.addTreeModelListener(new MyTreeModelListener());
         tree = new JTree(treeModel);
         tree.setEditable(true);
         tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
    tree.setShowsRootHandles(true);
         treeText.add(tree);
         //create the tabbed window           
    centerPane.setBorder(new javax.swing.border.EtchedBorder());
    formTab.setLayout(null);
    errorTab.setLayout(null);
    treeTab.setLayout(null);
    centerPane.addTab("Search Parameters", formTab);
    centerPane.addTab("Error Messages", errorTab);
    centerPane.addTab("Website Structure", treeTab);
              //add the tool bar and tabbed pane
              getContentPane().add(toolBar, java.awt.BorderLayout.NORTH);
    getContentPane().add(centerPane, java.awt.BorderLayout.CENTER);     
              *create the tool bar pane, a center pane, add the buttons,
              *labels, tabs, a text field for user input here
              javax.swing.JPanel toolBar = new javax.swing.JPanel();
              javax.swing.JButton start = new javax.swing.JButton();
              javax.swing.JButton cancel = new javax.swing.JButton();
              javax.swing.JButton close = new javax.swing.JButton();      
              javax.swing.JTabbedPane centerPane = new javax.swing.JTabbedPane();
              javax.swing.JPanel formTab = new javax.swing.JPanel();
              javax.swing.JLabel urlLabel = new javax.swing.JLabel();
              javax.swing.JLabel current = new javax.swing.JLabel();
              javax.swing.JTextField url = new javax.swing.JTextField();
              javax.swing.JPanel errorTab = new javax.swing.JPanel();
              javax.swing.JTextArea errorText = new javax.swing.JTextArea();
              javax.swing.JScrollPane errorPane = new javax.swing.JScrollPane();
              javax.swing.JPanel treeTab = new javax.swing.JPanel();
              javax.swing.JTextArea treeText = new javax.swing.JTextArea();
              javax.swing.JScrollPane treePane = new javax.swing.JScrollPane();
              javax.swing.JTree tree = new javax.swing.JTree();
              *show the gui
              public static void main(String args[])
              (new gui()).setVisible(true);
         *listen for the button presses and set the
         *boolean flag depending on which button is pressed
         class ButtonListener implements ActionListener
              public void actionPerformed(ActionEvent event)
                   Object object = event.getSource();
                   if (object == start)
                        run = true;
                        startActionPerformed(event);
                   if (object == cancel)
                        run = false;
                        startActionPerformed(event);
                   if (object == close)
                        System.exit(0);
         *this method is called when the start or
         *cancel button is pressed.
         void startActionPerformed (ActionEvent event)
              if (run == true && bgThread == null)
                   bgThread = new Thread(this);
                   bgThread.start();
                   //new line of code
                   treeText.addObject(msgInfo);
              if (run == false && bgThread != null)
                   webSpider.cancel();
         *this mehtod will start the background thred.
         *the background thread is required so that the
         *GUI is still displayed
         public void run()
              try
                   webSpider = new WebSpider(this);
                   webSpider.clear();
                   urlInput = new URL(url.getText());
                   webSpider.addURL(urlInput);
                   webSpider.run();
                   bgThread = null;
              catch (MalformedURLException e)
                   addressError addErr = new addressError();
                   addErr.addMsg = "URL ERROR - PLEASE CHECK";
                   SwingUtilities.invokeLater(addErr);
              *this method is called by the web spider
              *once a url is found. Validation of navigation
              *happens here.
              public boolean urlFound(URL urlInput,URL url)
                   CurrentlyProcessing pro = new CurrentlyProcessing();
              pro.msg = url.toString();
              SwingUtilities.invokeLater(pro);
              if (!testLink(url))
                        navigationError navErr = new navigationError();
                        navErr.navMsg = "Broken Link "+url+" caused on "+urlInput+"\n";
                        brokenUrl = url.toString();
                        return false;
              if (!url.getHost().equalsIgnoreCase(urlInput.getHost()))
                   return false;
              else
                   return true;
              *this method is returned if there is no link
              *on a web page, e.g. there us a dead end
              public void urlNotFound(URL urlInput)
                        deadEnd dEnd = new deadEnd();
                        dEnd.dEMsg = "No links on "+urlInput+"\n";
                        deadUrl = urlInput.toString();               
              *this method is called internally to check
         *that a link works
              protected boolean testLink(URL url)
              try
                   URLConnection connection = url.openConnection();
                   connection.connect();
                   goodUrl = url.toString();
                   return true;
              catch (IOException e)
                   return false;
         *this method is called when an error is
         *found.
              public void urlError(URL url)
              *this method is called when an email
              *address is found
              public void emailFound(String email)
              /*this method will update any errors found inc
              *address errors and broken links
              class addressError implements Runnable
                   public String addMsg;
                   public void run()
                        current.setText("Currently Processing: "+ addMsg);
                        errorText.append(addMsg);
              class navigationError implements Runnable
                   public String navMsg;
                   public void run()
                        errorText.append(navMsg);
              class deadEnd implements Runnable
                   public String dEMsg;
                   public void run()
                        errorText.append(dEMsg);
              *this method will update the currently
              *processing field on the GUI
              public class CurrentlyProcessing implements Runnable
                   public String msg;
              //new line
              public String msgInfo = msg;
              public void run()
                   current.setText("Currently Processing: " + msg );
         * NEW CODE
         * NEED THIS CODE SOMEWHERE
         * treeText.addObject(msgInfo);
         public DefaultMutableTreeNode addObject(Object child)
         DefaultMutableTreeNode parentNode = null;
         TreePath parentPath = tree.getSelectionPath();
         if (parentPath == null)
         parentNode = rootNode;
         else
         parentNode = (DefaultMutableTreeNode)
    (parentPath.getLastPathComponent());
         return addObject(parentNode, child, true);
         public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
    Object child)
         return addObject(parent, child, false);
         public DefaultMutableTreeNode addObject(DefaultMutableTreeNode parent,
         Object child,boolean shouldBeVisible)
         DefaultMutableTreeNode childNode = new DefaultMutableTreeNode(child);
         if (parent == null)
         parent = rootNode;
         treeModel.insertNodeInto(childNode, parent, parent.getChildCount());
         if (shouldBeVisible)
         tree.scrollPathToVisible(new TreePath(childNode.getPath()));
              return childNode;
         public class MyTreeModelListener implements TreeModelListener
              public void treeNodesChanged (TreeModelEvent e)
                   DefaultMutableTreeNode node;
                   node = (DefaultMutableTreeNode)
                   (e.getTreePath().getLastPathComponent());
                   try
                        int index = e.getChildIndices()[0];
                        node = (DefaultMutableTreeNode)
                        (node.getChildAt(index));
                   catch (NullPointerException exc)
              public void treeNodesInserted(TreeModelEvent e)
              public void treeStructureChanged(TreeModelEvent e)
              public void treeNodesRemoved(TreeModelEvent e)
    I beleive that this line of code is required:
    treeText.addObject(msgInfo);
    I have placed it where the action events start the spider, but i keep getting this error:
    cannot resolve symbol
    symbol : method addObject (java.lang.String)
    location: class javax.swing.JTextArea
    treeText.addObject(msgInfo);
    Also the jtree is not showing the window that I want it to and I am not too sure why. could you have a look to see why? i think it needs a fresh pair of eyes.
    Many thanks
    MrV

  • Help w/ clicking on leaves of tree node

    Hello,
    I am fairly new to Flex and coding in general, so please bare
    with me if my problems seems like a trivial one.
    I am trying to create a tree list, where the contents of the
    tree are actually links. For example, the top level of the tree
    node would be a category (companies), and the leaves of the tree
    would be the company names. In addition, I would like the user to
    be taken, in a new browser window, to a URL specified in the XML
    list when clicking on a company name.
    I am having problems resolving the click actions in the app.
    I can get the app to open and close the nodes of the tree cleanly,
    but when I try to add some code to take the user to a URL when
    clicking on a company name (leaf), I get errors.
    I am really stuck on how to read the click event in the tree
    list, run to the associated XML file to find the URL, then open up
    a new browser page to that URL.
    Can someone help me please? I've added a snippet of code to
    review.
    Thank you in advance!

    "hokudan" <[email protected]> wrote in
    message
    news:ghk08n$pdb$[email protected]..
    > Hi Amy,
    >
    > Thank you for your reply. Here are the errors that I'm
    getting in Flash:
    >
    > ReferenceError: Error #1069: Property source not found
    on mx.controls.Tree
    > and
    > there is no default value.
    > Two of the nodes in the tree also have a 'source' value
    that I've entered-
    > do
    > I need to make it a separate line instead of including
    it with the 'label'
    > field?
    Two things:
    1) I'm thinking the currentTarget of the itemClick event will
    be the tree
    itself, not the node. So you need to look at the selectedItem
    property to
    get the node. See the example under Handling Tree control
    events:
    http://livedocs.adobe.com/flex/3/html/help.html?content=dpcontrols_8.html
    2) To answer your question, you just need to reference it
    properly for
    however you set up the xml:
    http://dispatchevent.org/roger/as3-e4x-rundown/

  • TREE NODE IN F4 SEARCH HELP

    Hi All,
    Can anyone help me to implement Tree node in F4 Search help?
    Thanks
    E Karthikeyan

    SAP has provided a lot of sample programs for developing tree structures. Just go to SE38, type BCALVTREE and hit F4. You'll get different sample programs with a range of operations on trees
    Go through the link,
    http://www.sapdevelopment.co.uk/reporting/alv/alvtree.htm
    Slowly check this code..you will get idea of how to develop tree structure.
    REPORT y_hierarchies_in_tables
    NO STANDARD PAGE HEADING.
    PARAMETER: g_group TYPE grpname. " DEFAULT 'Z_GLAB0000'.
    DATA:
    g_setid TYPE setid,
    g_class TYPE setclass.
    DATA: lt_hier TYPE STANDARD TABLE OF sethier,
    lt_val TYPE STANDARD TABLE OF setvalues.
    DATA: hier LIKE sethier OCCURS 0 WITH HEADER LINE,
    val LIKE setvalues OCCURS 0 WITH HEADER LINE,
    setinfo LIKE setinfo OCCURS 0 WITH HEADER LINE.
    DATA: zaccbas(20) TYPE c OCCURS 0 WITH HEADER LINE.
    DATA: miss_val LIKE setvalues-from OCCURS 0 WITH HEADER LINE.
    DATA: table_name TYPE tabname,
    field_name TYPE setfld.
    DATA: ambiguity_flag TYPE c.
    Ambiguity check
    PERFORM ambiguity_check.
    Display Records
    PERFORM display_records.
    *& Form AMBIGUITY_CHECK
    Ambiguity check
    FORM ambiguity_check .
    DATA: it_abaplist LIKE abaplist OCCURS 0 WITH HEADER LINE.
    DATA: BEGIN OF it_ascilist OCCURS 0,
    zeile(256) TYPE c,
    END OF it_ascilist.
    DATA: flag.
    SUBMIT rgsovl00 "VIA SELECTION-SCREEN
    WITH p_shrtn = g_group
    WITH path = 'X'
    EXPORTING LIST TO MEMORY
    AND RETURN.
    CALL FUNCTION 'LIST_FROM_MEMORY'
    TABLES
    listobject = it_abaplist
    EXCEPTIONS
    not_found = 1
    OTHERS = 2.
    CALL FUNCTION 'LIST_TO_ASCI'
    TABLES
    listasci = it_ascilist
    listobject = it_abaplist
    EXCEPTIONS
    empty_list = 1
    list_index_invalid = 2
    OTHERS = 3 .
    LOOP AT it_ascilist.
    IF it_ascilist-zeile = text-001.
    flag = 'X'.
    ENDIF.
    IF flag = 'X' AND
    it_ascilist-zeile = text-002.
    ambiguity_flag = 'X'.
    CLEAR flag.
    ENDIF.
    ENDLOOP.
    FREE MEMORY.
    ENDFORM. " AMBIGUITY_CHECK
    *& Form DISPLAY_RECORDS
    Display the Records
    FORM display_records .
    PERFORM get_records.
    PERFORM header_data.
    PERFORM item_data.
    ENDFORM. " DISPLAY_RECORDS
    *& Form GET_RECORDS
    Get all the Node values
    FORM get_records .
    Get the ID name for the Hierarchy
    CALL FUNCTION 'G_SET_GET_ID_FROM_NAME'
    EXPORTING
    shortname = g_group
    setclass = g_class
    old_setid = g_setid
    IMPORTING
    new_setid = g_setid.
    Get the Table and Field name for the Top Node
    CALL FUNCTION 'G_SET_GET_INFO'
    EXPORTING
    setname = g_setid
    no_set_title = 'X'
    use_table_buffer = 'X'
    IMPORTING
    info = setinfo.
    table_name = setinfo-tabname.
    field_name = setinfo-fld.
    Get all the Nodes for the Hierarchy
    CALL FUNCTION 'G_SET_TREE_IMPORT'
    EXPORTING
    no_descriptions = ' '
    no_rw_info = 'X'
    setid = g_setid
    TABLES
    set_hierarchy = lt_hier
    set_values = lt_val.
    hier[] = lt_hier.
    val[] = lt_val.
    SELECT (field_name) FROM (table_name) INTO TABLE zaccbas.
    LOOP AT zaccbas.
    READ TABLE val WITH KEY FROM = zaccbas.
    IF sy-subrc = 0.
    DELETE zaccbas.
    CLEAR zaccbas.
    DELETE val INDEX sy-tabix.
    CLEAR val.
    ENDIF.
    ENDLOOP.
    ENDFORM. " GET_RECORDS
    *& Form HEADER_DATA
    Header Data
    FORM header_data .
    DATA: desc TYPE settext.
    READ TABLE hier WITH KEY fieldname = field_name
    shortname = g_group.
    IF sy-subrc = 0.
    desc = hier-descript.
    ENDIF.
    SKIP.
    WRITE: 'Node :',g_group.
    WRITE:75 'User name :', sy-uname.
    WRITE:/ 'Description :', desc.
    WRITE:75 'Date:', sy-datum.
    WRITE:/ 'Table Name :' , table_name.
    WRITE:75 'Time:', sy-timlo.
    WRITE:/ 'Field Name :', field_name.
    write:75 'Client:', SY-MANDT.
    skip.
    IF ambiguity_flag = 'X'.
    WRITE:/ 'Ambiguity Check :'. WRITE: 'Success' COLOR 5.
    ELSE.
    WRITE:/ 'Ambiguity Check :'. WRITE: 'Failed' COLOR 6 .
    ENDIF.
    WRITE:/ sy-uline.
    WRITE:/37 'Validation for Hierarchy'.
    WRITE:/ sy-uline.
    ENDFORM. " HEADER_DATA
    *& Form ITEM_DATA
    Output Report for Nodes
    FORM item_data .
    IF NOT zaccbas[] IS INITIAL.
    WRITE:/ 'Missing Records from Hierarchy' COLOR 3.
    LOOP AT zaccbas.
    WRITE:/ zaccbas.
    ENDLOOP.
    ENDIF.
    IF NOT val[] IS INITIAL.
    SKIP 1.
    WRITE:/ 'Additional Records in Hierarchy' COLOR 3.
    LOOP AT val.
    WRITE:/ val-from. ", 28 val-DESCRIPT.
    ENDLOOP.
    ELSEIF ZACCBAS[] IS INITIAL.
    WRITE:/ 'No Missing Records Found' COLOR 3.
    ENDIF.
    ENDFORM. " ITEM_DATA
    Thanks,
    Sakthi C
    *Rewards if useful*

  • Help:create tree node dynamically from java code...

    hi there...can anyone give me solution how to create or add tree node dynamically from java code???
    currently i am using tree node to handle my menu...i try to create tree and add treenode dynamically from .java page, but it failed...can anyone give solution how to create tree ui from java code, so i can create a dynamic menu...thanz before...

    Hi:
    Just put the statements you would normally put on a sqlplus command line in jdbc statements and execute them?
    http://www-db.stanford.edu/~ullman/fcdb/oracle/or-jdbc.html#0.1_executeUpdate
    MJG

  • Help for Activating Editing Mode on F2 Keyboard Click for a Tree Node

    I have a Jtree with several Nodes on the Left Pane. On the Right Pane I have a nodes corresponding Screen with many properties. There is a way to change the Node Name by editing the Name Field property on the Right.
    I want to Edit the tree Node name by Clicking F2 on the selected Node, Get it in the Editable Mode, Change the name and press enter. How Do I activate this editable Mode on Click of Keyboard F2 Button.

    tree.setEditable( true );

  • How to drag and drop a sub tree between 2 treeview?

    Suppose I have 2 tree rendered in 2 treeview. Then I want to drag and drop any subtree on any node between the 2 tree.
    For example, in tree 1, if I drag node node1 and drop it on tree 2 node node2. I want all nodes from node1(subtree) moved to node 2 in tree 2.
    How can I do it? Should I code for treeview 1 begindrag event, and code for treeview 2 dragenter event?
    and how to move a sub tree with pb built-in function?

    Hi Kent,
    I have just experimented with drag and drop between treeviews. Below is your bare minimum and caters for one node only. It does not drag any children along. If you drag an item it loses any children. Although it works both ways and within.
    The handle is set in the dragbegin events.
    In the dragdrop events you get source as an argument which is a pointer to the treeview where the drag started.
    You get the node using GetItem ( ref treeviewitem ), then InsertItemSort as a child of the node dropped on.
    NOTE: Must uncheck DisableDragAndDrop property for both treeviews.
    // Instance Variable
    ulong draggedhandle
    type tv_1 from treeview within w_treehop
    string dragicon = "Form!"
    boolean dragauto = true
    boolean disabledragdrop = false
    end type
    event begindrag;
    draggedhandle = handle
    end event
    event dragdrop;
    treeview tvSource
    treeviewitem ltvidropped, ltvidragged
    tvSource = source
    if draggedhandle > 0
      if handle <> draggedhandle or tvSource <> this then
        tvSource.GetItem( draggedhandle , ltvidragged )
        this.GetItem( handle , ltvidropped)
        this.Insertitemsort( handle, ltvidragged )
        tvSource.Deleteitem( draggedhandle )
        draggedhandle = 0
      end if
    end if
    end event
    type tv_2 from treeview within w_treehop
    string dragicon = "Form!"
    boolean dragauto = true
    boolean disabledragdrop = false
    end type
    event begindrag;
    draggedhandle = handle
    end event
    event dragdrop;
    treeview tvSource
    treeviewitem ltvidropped, ltvidragged
    tvSource = source
    if draggedhandle > 0
      if handle <> draggedhandle or tvSource <> this then
        tvSource.GetItem( draggedhandle , ltvidragged )
        this.GetItem( handle , ltvidropped)
        this.Insertitemsort( handle, ltvidragged )
        tvSource.Deleteitem( draggedhandle )
        draggedhandle = 0
      end if
    end if
    end event
    To carry over nested treeview items (children) you can use FindItem ( draggedhandle, navigationcode )
    navigationcode as per help:
         ChildTreeItem! The first child of itemhandle.
         NextTreeItem! The sibling after itemhandle. A sibling is an item at the same level with the same parent.
    HTH
    Lars

  • Context Menu on the right click of af:tree node

    Hi Experts,
    I am using drag and drop functionality in af:tree.In that i used one tree for drag source and another one tree for drop target,and it is working as expected.
    Now I want to bring one additional option in the context menu of the target tree node that is ,when i right click on any of the target tree node in addition to the default menu options like "Collapse","Expand" i want to add one more option .For this i added "contextMenu" facet after the "nodeStamp" facet inside the tree.
    *<f:facet name="contextMenu">*
    *<af:popup id="p1">*
    *<af:menu text="Delete" id="m1">*
    *<af:commandMenuItem text="Delete" id="cmi1"*
    *action="#{myWorkflow.deleteWorkflowNode}"/>*
    *</af:menu>*
    *</af:popup>*
    *</f:facet*>
    Now the problem is : before using drag and drop the context menu workes without any problem .But after using drag and drop the context menu is not popped up.
    can anybody help me to resolve this?
    Thanks,
    Priya.

    Hi Frank,
    1. I am using JDeveloper 11.1.1.3 version
    2. Drop target tree is having the context menu.
    3. Yes . In Drop event am calling a backing bean method with return type DnDAction and i return the value as DnDAction.MOVE to reflect the changes in the database table to the target tree.
    Regards,
    Priya.

  • Highlighted drop source from tree control?

    When a user drop an item or node from one tree to another, is
    there a way to detect where the user wants to drop the item/node?
    Let's say a tree showing a company structure with different
    departments and managers and a list of people under the managers.
    Such as:
    Company A
    L---> R&D
    ..........L---> Research
    ..........L---> Development
    .......................L---> UI
    ................................L---> Manager A
    .............................................L--->
    Personal a1
    .............................................L--->
    Personal a2
    .............................................L--->
    Personal a3
    .......................L---> Algorithm
    ................................L---> Manager B
    .............................................L--->
    Personal b1
    .............................................L--->
    Personal b2
    .............................................L--->
    Personal b3
    .......................L---> Architecture
    ................................L---> Manager C
    .............................................L--->
    Personal c1
    .............................................L--->
    Personal c2
    .............................................L--->
    Personal c3
    A user can suffle the people under different managers bsed on
    the project phases. If Personal c1 & c2 complete their tasks,
    they get moved to Manager A to help out the UI. In this case, I
    need to know where the c1 & c2 get move to. All personals can
    only be a child of Managers. If a user accidently drop them at
    category or department level, the move should be ignored. How do I
    do this? Is it possible to do this within ONE tree control rather
    than two? Please help! Any input is appriciated!

    Yes. I am able to check the dragged data. However, I cannot
    grab the dropped data to compare and refuse the drop if the rule is
    not allowed. If the drag and drop source are the same, it wouldn't
    make since to use drag_enter event to check since it is moving a
    node in the same tree.

  •      Need coordinate for particular tree node as currently expanded

    Hi All,
    i am working in flex for the past two months,currently i am
    working on the drag and drop on a tree , where i am able to drag
    one tree leaf node to another another tree leaf node and i am able
    to draw a line between the two leaf node indicating that this has
    been dragged from the previous tree of a particular node to the
    current node of the tree.
    The problem which i am facing is that when i collapse the
    expanded tree , the line which i have drawn is not able to
    synchronize with the tree expand or collapse (the line remains in
    the same position even when the particular leaf node move down coz
    of expansion of the above tree node.)
    any help will be appreciated.

    there is a private function in the tree.as class:
    private function getVisibleChildrenCount(item:Object):int
    that I can use by multiplying how many children there are by
    how tall each item "physically" displays on the screen as, but I
    want to get that publicly. I don't want to go about hacking the
    tree.as code, that's poor form in the highest. Does anybody else
    have any ideas...
    please?

  • How to resize a custom tree node like you would a JFrame window?

    Hello,
    I am trying to resize a custom tree node like you would a JFrame window.
    As with a JFrame, when your mouse crosses the Border, the cursor should change and you are able to drag the edge to resize the node.
    However, I am faced with a problem. Border cannot detect this and I dont want to use a mouse motion listener (with a large number of nodes, I fear it will be inefficient, calculating every node's position constantly).
    import java.awt.BorderLayout;
    import java.awt.Color;
    import java.awt.Component;
    import java.awt.Dimension;
    import java.awt.Insets;
    import java.util.EventObject;
    import javax.swing.BorderFactory;
    import javax.swing.Box;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JScrollPane;
    import javax.swing.JTextArea;
    import javax.swing.JTree;
    import javax.swing.tree.DefaultMutableTreeNode;
    import javax.swing.tree.DefaultTreeCellEditor;
    import javax.swing.tree.DefaultTreeCellRenderer;
    import javax.swing.tree.DefaultTreeModel;
    import javax.swing.tree.TreeSelectionModel;
    public class ResizeNode extends JPanel {
           AnilTreeCellRenderer2 atcr;
           AnilTreeCellEditor2 atce;
           DefaultTreeModel treeModel;
           JTree tree;
           DefaultMutableTreeNode markedNode = null;
         public ResizeNode() {
                super(new BorderLayout());
                   treeModel = new DefaultTreeModel(null);
                   tree = new JTree(treeModel);          
                  tree.setEditable(true);
                   tree.getSelectionModel().setSelectionMode(
                             TreeSelectionModel.SINGLE_TREE_SELECTION);
                   tree.setShowsRootHandles(true);
                  tree.setCellRenderer(atcr = new AnilTreeCellRenderer2());
                  tree.setCellEditor(atce = new AnilTreeCellEditor2(tree, atcr));
                   JScrollPane scrollPane = new JScrollPane(tree);
                   add(scrollPane,BorderLayout.CENTER);
         public void setRootNode(DefaultMutableTreeNode node) {
              treeModel.setRoot(node);
              treeModel.reload();
           public static void main(String[] args){
                ResizeNode tb = new ResizeNode();
                tb.setPreferredSize(new Dimension(400,200));
                  JFrame frame = new JFrame("ResizeNode");
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.setContentPane(tb);
                  frame.setSize(400, 200);
                  frame.pack();
                  frame.setVisible(true);
                  tb.populate();
         private void populate() {
              TextAreaNode2 r = new TextAreaNode2(this);
               setRootNode(r);
               TextAreaNode2 a = new TextAreaNode2(this);
               treeModel.insertNodeInto(a, r, r.getChildCount());          
    class AnilTreeCellRenderer2 extends DefaultTreeCellRenderer{
    TreeBasic panel;
    DefaultMutableTreeNode currentNode;
      public AnilTreeCellRenderer2() {
         super();
    public Component getTreeCellRendererComponent
       (JTree tree, Object value, boolean selected, boolean expanded,
       boolean leaf, int row, boolean hasFocus){
         TextAreaNode2 currentNode = (TextAreaNode2)value;
         NodeGUI2 gNode = (NodeGUI2) currentNode.gNode;
        return gNode.box;
    class AnilTreeCellEditor2 extends DefaultTreeCellEditor{
      DefaultTreeCellRenderer rend;
      public AnilTreeCellEditor2(JTree tree, DefaultTreeCellRenderer r){
        super(tree, r);
        rend = r;
      public Component getTreeCellEditorComponent(JTree tree, Object value,
       boolean isSelected, boolean expanded, boolean leaf, int row){
        return rend.getTreeCellRendererComponent(tree, value, isSelected, expanded,
         leaf, row, true);
      public boolean isCellEditable(EventObject event){
        return true;
    class NodeGUI2 {
         final ResizeNode view;
         Box box = Box.createVerticalBox();
         final JTextArea aa = new JTextArea( 1, 5 );
         final JTextArea aaa = new JTextArea( 1, 8 );
         NodeGUI2( ResizeNode view_ ) {
              this.view = view_;
              box.add( aa );
              aa.setBorder( BorderFactory.createMatteBorder( 0, 0, 1, 0, Color.GREEN ) );
              box.add( aaa );
              box.setBorder( BorderFactory.createMatteBorder( 5, 5, 5, 5, Color.CYAN ) );
         private Dimension getEditorPreferredSize() {
              Insets insets = box.getInsets();
              Dimension boxSize = box.getPreferredSize();
              Dimension aaSize = aa.getPreferredSize();
              Dimension aaaSize = aaa.getPreferredSize();
              int height = aaSize.height + aaaSize.height + insets.top + insets.bottom;
              int width = Math.max( aaSize.width, aaaSize.width );
              if ( width < boxSize.width )
                   width += insets.right + insets.left + 3;     // 3 for cursor
              return new Dimension( width, height );               
    class TextAreaNode2 extends DefaultMutableTreeNode {  
         NodeGUI2 gNode;
         TextAreaNode2(ResizeNode view_) {     
              gNode = new NodeGUI2(view_);
    }

    the node on the tree is only painted on using the
    renderer to do the painting work. A mouse listener
    has to be added to the tree, and when moved over an
    area, you have to determine if you are over the
    border and which direction to update the cursor and
    to know which way to resize when dragged. One of the
    BasicRootPaneUI has some code that can help determine
    that.Thanks for replying. What is your opinion on this alternative idea that I just had?
    I am wondering if it might be easier to have a toggle button in the node that you click when you want to resize the node. Then a mouse-down and dragging the mouse will resize the node. Mouse-up will reset the toggle button, and so will mouse down in an invalid area.
    Anil

Maybe you are looking for