Build a JTree from data

Hello everyone,
I have to build a JTree from a table data from database. The table structure is
(id,parent_id,name). In order to build the tree, I have to the following 2 loop searching for the parent_id
while (i<size){
while(j<size){
//find it's parent_id
j++;
i++;
It is too slow! Can anyone help me?
Thanks!
--tc                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

You just add children to whatever the parent node is for that object.DefaultMutableTreeNode root = new DefaultMutableTreeNode();
child1 = new DefaultMutableTreeNode();
root.add( child1 );
grandChild = new DefaultMutableTreeNode();
child1.add( grandChild );
greatGrandChild = new DefaultMutableTreeNode();
grandChild.add( greatGrandChild );Etc.

Similar Messages

  • How to build a String from Date?

    How to build a String from class Date?
    How to get the year, month, day, hour ... from a Date object.

    Ok to build a string use this function in java.util.Date
    toString()
    TO get year, date, etc u can use the following functions
    getYear()
    getDate()
    This link might help u more
    http://java.sun.com/products/jdk/1.1/docs/api/java.util.Date.html

  • Building a JTree from a Database

    Hi everyone,
    I'm sort of new to Java. 3 months and still struggling.
    My challenge is I would like to populate a tree from a Database. The problem is I do not know in advance how many children, children and children a node will have. There could be none or many.
    For sure I'm able to build the root of the table and the involved folders both are coming from a database. The tables for this are like the following.
    -root table-
    root_id
    root_name
    -folders table-
    folder_id
    folder_name
    Now each folder, and there are at least one can have children and the children could have children and so on. This is more or less infinit. Here is the children table
    -folder_contents-
    content_id
    content_name
    content_folder_id
    parent_id
    A record might look like this where the parent it is a record in the same table
    1, 1.0, 1, null
    2, 1.1, 1, 1
    3, 1.2, 1, 2
    4, 2.0, 1, null
    3, 2.1, 1, 4
    and so on
    Some insight or code snippet would be highly appreciated and rewarded with Duke Dollars
    Thanks Oscar

    Hope this helps
    http://forum.java.sun.com/thread.jsp?forum=57&thread=118604
    http://forum.java.sun.com/thread.jsp?forum=57&thread=149431
    http://forum.java.sun.com/thread.jsp?forum=57&thread=121264

  • Building jtree from database query

    I am trying to build a JTREE from a database result-set. The resultset is listed below. I'm thinking I can somehow build a dynamic array of objects to build a TreePath, then use that to build the JTREE. Any input is appreciated.
    ResultSet Output:
    Here is how the results would be retrieved from the database (including the order of the output).
    usr 1
    local 2
    sbin 2 file4
    bin 3 file1
    bin 3 file2
    logs 3 file3
    tmpdir 4
    The first column is the directory name, the second column is the directory/file level/position, and the third column is the filename, if one exists.
    So from above:
    /usr/local/sbin has file "file4"
    /usr/local/bin has files "file1" and "file2"
    /usr/local/logs has file "file3" and directory "tmpdir"
    How could I gather this information into an appropriate structure and create a JTREE from it.
    Thanks.
    -Jim

    So each line would:basically...
    If I don't know the entire path of the parent (because I've read in a
    line that only has the "one-up" parent name) .... However, when I
    read the line from the database result-set, I don't know where "local" is.See... that's another problem with that data. Maybe you know cuz it's the last node if it's all in a proper order. In which case maybe you only need to hold the last parent node... Some recursive function would be useful.
    If I were going to store the data, I would store either the name as a full path:
    /usr
    /usr/local
    /usr/loca/bin
    or
    usr /
    local /usr
    bin /usr/local
    If you have that, it might be easier to figure out without having to worry about what belongs where.

  • Building a table with data from a query

    Hello group,
    Is it possible to build a table with the output from a query. We would like to build queries on precalculated data, and want to use other queries for the precalculation.
    Regards, Léon Hoeneveld

    Hi Léon,
    use transaction RSANWB.
    It should be available from 3.0.
    regards
    Siggi
    Message was edited by: Siegfried Szameitat

  • Building JTrees from Filename strings????

    Does anybody know or have code to build JTrees from fileName string so that the tree is expandable and uses expansion listeners.

    Does anybody have code that allows you to show the local filesystem and also file strings contained say in a file so they can both be viewed at the same time. ie if you know somebody else has a file but you want it reflected in your local filesystem.
    Come on somebody must

  • 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

  • Creating dynamically JTree from database values

    Hi,
    I have a local database with some node values. I receive these values from database as a String[].
    short example:
    String[] Values = {"mainNode","Processors","mainNode","RAM","mainNode","Monitors",
    "Processors","INTEL","Processors","AMD","RAM","Kingston","RAM","GoodRAM",
    "Kingston","400MHz","Kingston","433MHz"}First value is higher node, second is a child.
    I'd like to produce dynamically JTree from Values[] like below:
    MainNode
    |----Processors
          |----INTEL
          |----AMD
    |----RAM
          |----Kingston
                |----400MHz
                |----433MHz
          |----GoodRam
    |----MonitorsI can't build up any working and fast solution :(
    Can anyone help me ?
    Please for any advices (samples) which will help me to apply it.
    Dearly regards!

    This is a relatively straight forward task but it smacks of being homework so unless you post what you have already done you are unlikely to be given any code.
    As a hint -
    Go through the data creating a Map between the parent value and a child DefaultMutableTreeNode which contains as user object the child String.
    When you extract a parent String from the data lookup the parent DefaultMutableTreeNode in the map and add the child DefaultMutableTreeNode to the parent DefaultMutableTreeNode.
    Note - All the map is doing is giving you a quick way of looking up a DefaultMutableTreeNode given a parent name.
    Note - that your tree will have problems if the same value appears in two or more branches!

  • Create JTree from XML

    hi. I have created a simple XML file which contains a hierarchical structure of strings.
    Also, I have created a SAXParser to read from the xml.
    But I don't know how to put this structure in a JTree.
    I don't want the tree to appear on my screen. I just want to access certain nodes at different times.
    Any help?

    Hello,
    If it's not to display it, you certainly don't need a JTree to store your data.
    Maybe you need to use a DOMParser instead but that shouldn't prevent you from building a more appropriate data model.

  • Report Generation - Build an exe from a PC with different Office Version

    Hi,
     I want to build an exe from a VI that uses Report Generation Toolkit. The application has to be deployed on several PCs that use Office 2000. During development phase I installed on my PC, Office 2000 and everything was ok. After I was done with it, I reinstalled Office 2007. So, the Report Generation Toolkit from my PC is for Office 2000 (it was installed when I had Office 2000 on my PC).
     These days I had to fix some bugs from my application, I made a new exe but the part that generates Word reports (using RGT) is not working anymore - I received that error with -35...9935 (or something like this).
     I tried to search for the problem and I found it: with exactly the same VI's (_Word Dynamic VIs.vi - for Office 2000) the invoke nodes from a PC with Office 2007 and a PC Office 2000 look different. For example in Word_Open_Document.vi, the invoke node Document is different for a PC with Office 2000 + RGT for 2000 and a PC with Office 2007 + RGT for Office 2000 (no mistake).
     So, I've tried to copy the VI's from a PC with Office 2000 + RGT 2000 to my PC but I cannot build it because I get the error: There are some errors in _Word Dynamic VIs.vi (the invoke nodes do not fit).
    Finally my question is: How can I build the exe on my PC: Office 2007 but with RGT for Office 2000??
    Thanks,
    Paul
    Solved!
    Go to Solution.

    Hi,
    Thank you for your advice. Can you please tell me what you want to say with the wrapper vi? I don't really understand what you mean.
    By the way, I solved the problem. I discovered that the Invoke Nodes are updated based on the Object Library for the ActiveX control (in this case the MS Office). The data types are store in the msword9.olb (version 9 - for office 2000 in Office folder) and msword.olb (version 12 - for office 2007 also in Office folder). I tried to register the msword9.olb (using the regsvr32.exe) but it doesn't work for olb files - I need the ocx or dll. But, if I replace the msword.olb from Office 2007 with msword9.olb from Office 2000 everything work.
    Ok, steps that have to be done:
    1. Install the RGT for Office 2000 on the PC
    2. DO NOT Change anything in _Word_Dynamic VIs.vi. When Office 2007 is installed the VI arrow should be broken (error in VI)
    3. Copy the msword9.olb from a system with Office 2000 (or your version) and copy it to your system with Office 2007 with the new name msword.olb. DO NOT FORGET to make a backup of the original MS Office 2007 file and to restore it at the end.
    4. After the new msword.olb is there, the _Word_Dynamic VIs.vi should have no error
    5. Build your exe application
    6. Restore the old msword.olb
    7. ENJOY your life !
    I hope this is useful also for somebody else.
    Paulie

  • List Builder only shows 1 data set at a time

    Am attempting to get a list builder to display multiple data sets but am hitting a wall.  When a 1st data set is selected then all OK.  Add 2nd data set and update list and only 1st is shown.  Remove 1st and update and data is refreshed to 2nd list.  Add 3rd and repeats itself and so on.  Looks like all OK based on the sample but built from scratch and think missing something simple in the destination range (although appears fine).  thoughts?

    Can you describe this in more detail? 
    How are your datasets defined in your excel model and how are your target cells formatted?
    How are you trying to display the two resultsets in list builder in the first place?  The cell range has to be contiguous for list builder to work.

  • Create printouts from data submitted in a form.

    Long story short:
    I'm looking to set up a system that automatically creates a document from data submitted in a form. So imagine I type "Jason" in the name field, "Orangutans" in the favorite animal field, and when I click print I'm presented with an A4/Letter document that says "my name is Jason and I love Orangutans" and the background is covered in cute orange apes. Where do I start?
    Long story long:
    I work at a computer store and due to my experience with Adobe products* I've been tasked with creating all the signage in the store. I've been doing all the signs for a year now and now we have a bunch of different signs that need printing every day. The most in-depth and time-consuming ones for me are signs for Trade-In computers. Unlike new computers, the specs are always different based on the particular model we buyback from the client. There are all kinds of fields that are different in each case.
    As it stands, I have an illustrator file with all the information in the right place, and when a computer comes in I take all the specs, fill in the right boxes and unhide the image layer so I get an image of the corresponding model on my document. This takes considerable time, and means the process is specific to me, i.e if I'm not in the store, the computers don't get put up for sale beacuse we can't add a spec/price sheet.
    What I want to do is automate the process so that anyone in the store can make these signs. All they will have to do is fill in a form (online or locally) that asks for model, year, RAM, HDD, etc**. Then when they click submit it returns a completed sign that they can print and put up next to the computer.
    I'm not entirely sure how to accomplish this. I've looked at Adobe's free online FormCreater***, and I like the simple data output that it creates. However, I'm uncertain as to my next steps. I imagine I'll need it to send the results to a computer with blank templates for the Trade-In computers. It would then need to populate the applicable fields and automate all the work I usually do.
    Where should I start? I'm willing to learn anything to get this working.
    Thanks,
    Jason
    *Illustrator, Photoshop, Flash, inDesign
    **Total of ~18 text and 4 image fields need to be changed per sign.
    ***http://www.adobe.com/ca/products/acrobat/form-creator.html

    I'm willing to learn anything to get this working.
    Excellent! Right attitude.
    Where should I start?
    With my favorite "graphics program": FileMaker Pro. (Yep. My favorite graphics-project tool is a relational database program.)
    You see, you've discovered something that graphics people are discovering with increasing frequency all the time: Your project is not a graphics problem. It's a data problem.
    Note how little of your problem has to do with graphics. Emphasis mine:
    ...we have a bunch of different signs that need printing every day.
    the specs are always different based on the particular model
    automate the process so that anyone in the store can make these signs
    All they will have to do is fill in a form (online or locally)
    an image of the corresponding model
    See if this scenario sounds appealing:
    You have on your computer a single file, named TradeIns. You or one of your authorized users doubleClick it. It opens to a nicely organized form that is completely self-explanatory; requires absolutely no training to use.
    It's completely idiot proof. The user doesn't have to know anything about any graphics program. He can't break anything.
    Consistency is maintained because everything that can be automated is. Dependency intelligence is built in. Popup menus limit data entries to legitimate choices (ex: Models). Subsequent data entry choices are automatically filtered based on data already entered (ex: RAM configurations limited to those possible for Model). User prompts and hints (highlighting, event-driven messages, tooltips, data validation, etc.) make sure that all required information is entered.
    When the data entry is done, the user clicks a button labeled Print Preview: A3 Poster. The display automatically changes to a pre-defined A3 formatted layout with all the data graphically styled (Headline, descriptive blurb, bullet list of features, price, etc., etc.), the company logo and contact info in place, and a graphic of the appropriate model appears in the background. The user clicks a button labeled Print Poster. Next to it, by the way, is a button labeled Email Poster To...
    If you want, you can enable up to five people concurrently to access and interact with the solution in their web browsers from anywhere. So the data entry can be performed by staff members who logon (according to access priviledges you define and control down to the individual field level if need be) in the office, from home, or even on their iPhone. Multiple users can enter/edit data at the same time.
    It's 2:00 Tuesday when Customer leaves with his new machine. You clean up his trade-in a little; put it on the display shelf. Pull out your iPhone and take a photo of it. Tap the specs in. The data, including the photo, are simultaneously entered into the database. You lock the door and go home at 5:00, confident that a formatted sales flier of "Just Arrived" trade-ins will be automatically emailed to your mail list before you get home.
    You, having admin priviledges, can add to, alter, elaborate upon the functionality (ex; add an automatic price calculator) anytime you need, with no downtime on the system.
    How difficult, time-consuming is this?
    Once the requirement details are nailed down, and the raw beginning data for populating values lists is provided, an intermediate level FileMaker developer could build the above-described solution and have it up and running, ready for data entry, in less than a day, easy.
    Cost? $500 for one copy of FileMaker Pro Advanced. That's it. (And...*achem*...it's not rented; it's a normal perpetual license.) And with it you can build an unlimited number of other data-driven solutions for your business. You can even bind them as fully-functional standalone applications which you can distribute without royalties.
    Based on what you've described so far, the solution's starting data schema would be very simple:
    Create a new database with three related tables:
    Models
    Trade Ins
    Specs
    The fields for each table would be something like this:
    Models
    Model ID (primary key; text; unique)
    Model Name (text)
    Brand (text)
    Image (container)
    Trade Ins
    Trade In ID (primary key; text; computer's serial number)
    Model ID (foreign key; text; value list)
    Specs
    Spec ID (auto-enter serial number)
    Model ID (foreign key)
    Trade In ID (foreign key)
    Spec Name (value list)
    Description (text)
    You'd have two Layouts (screens): Data Entry and A3 Poster. You could build as many additional Layouts to display whatever combinations of the data you want for as many purposes as you may encounter. Export to PDFs or Excel spreadsheets any time. Build automated reports with live graphs, use conditional formatting, automate with scripts, etc., etc.
    Marvelous program. Every business should have it.
    JET

  • Error when  building a report from 2 different subject areas

    Hello Experts,
    I am using obiee 11.1.1.5.
    I have 5 dimension D1,D2,D3,D4,D5 connected to fact1 and 4 dimension connected to fact2 such as D1,D2,D6,D7.
    where D1,D2 is common to both the facts.
    Fact1 Is in subject area 1 and Fact2 is in subject area2.
    I need to create a report by adding columns of  subject area 1 and 2 with columns from all the dimensions D1,D2....D7.
    As of now i am getting error stating "No fact table exists at the requested level of detail " when i try to add columns from 2 different subject areas.
    Can anyone help me in solving the above problem.
    Is there any prerequisite to be taken care when  building a report from 2 different subject areas.
    Regards,
    NN

    Hello Nagireddy,
    So kind of you, for your quick reply
    I was able to solve the error by doing below steps in additional what you have specified
    -->For the fact table LTSs, set the logical level in the Content tab to the dimension's lowest level for each conforming dimension (leave the non-conforming dimensions level blank).
    Now I have another requirement i,e
    I need to have non measure columns such as Date into the newly created fact in BMM layer.
    I tried doing the steps which I followed for measure column, but it is throwing the same error which I get earlier.
    Below is the error
    Error Codes: OPR4ONWY:U9IM8TAC:OI2DL65P
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 43113] Message returned from OBIS. [nQSError: 43119] Query Failed: [nQSError: 14025] No fact table exists at the requested level of detail:
    Let me know if have any suggestions

  • Disallowed implicit conversion from data type datetime to data type timestamp

    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q

    quote:
    Originally posted by:
    quiet1
    Received error: [Macromedia][SQLServer JDBC
    Driver][SQLServer]Disallowed implicit conversion from data type
    datetime to data type timestamp, table 'myTbl', column 'duration'.
    Use the CONVERT function to run this query.
    I have a field named duration hh:mm:ss.lll that I am trying
    to insert into MS SQL. DB has field defined as [duration]
    [timestamp] NOT NULL,
    My insert has this: INSERT INTO myTbl( duration) VALUES(
    <cfqueryparam value="2006-05-26 11:12:13"
    cfsqltype="CF_SQL_TIMESTAMP"/> )
    Why does this not work? rrrrrrrrrrrrrr! BTW: also tried with
    seconds as 13.111 which did not work. Does the db duration need to
    be date? I just want to store a duration for the time of a movie...
    10 Q
    Duration as a timestamp? How odd, most people would store it
    as an integer. Or, if you want to build your own string, the syntax
    is {ts 'yyyy-mm-dd hh:mm:ss'}. The seconds might not be required.
    In any event, use createodbcdatetime() for the value you want
    to put into your table.

  • JTree from root

    If a TreeNode has been set as the root of a JTree, is there any method that will recover the JTree from the TreeNode (other than just coding the info into the program's data when you set the node as root)?

    I managed to come up with a pair of jtree/node classes that do what I want, e.g. node.addNotify(newChild) causes the jtree display to update; I think this is better than node.add(newChild);<something update the jtree display> on the basis that `an intelligent object moves complexity from the many to the few'(Cline & Lomow _C++ FAQS+ p 42).  I'm just surprised that this isn't made easier to do.

Maybe you are looking for

  • Mail sent from iPad not appearing on desktop (windows) pc

    Have had to change my BT Yahoo email account to BT Mail so on the iPad deleted the BT yahoo account and then added the BT mail account.  Problem is that mail sent from iPad no longer appears on the (windows) pc. What am I missing ipad iOs 7.1.2

  • Re: Printer connection to hub

    Hi Billy, I'm running Win XP PRO and followed your instructions to the letter but for some reason it didn't work for me?  When trying to print, I get the audio saying printing started and then nothing. The first time I tried to print it prompted me w

  • Wireless G only on Vista but N works on Mac OS X side...

    Uhh... Yeah. What's the deal!? I have an excellent connection and speed on my OS X side with Wireless N enabled but on Vista it is connected at 6MB/s and says it's only on Wireless G. What gives? I have a new 500GB Time Capsule router that works with

  • Webservice response (XML response) with tag not mandatory

    Hello all, I have a problem with a webservice response. I implemented a wsdl who created some method to call webservices (Methox X, Y ,Z). I call the method 'X' with a table of string who have3 values in input, and I have in a  XML Answer of the webs

  • Oracle d2k connectivity please read this

    i have installed personal oracle 8i on win 98 se but unable to connect from developer 6.0 on the same machine .i cant even create simple forms . i have tried on both windows 98 and windows 95. take for example i want to prepare a simple forms which c