Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4108380
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:38:47+00:00 2026-05-20T21:38:47+00:00

UPDATE : It doesn’t have to be using static files. Is using a global

  • 0

UPDATE: It doesn’t have to be using static files. Is using a global variable string and listening to if that changed in length possible?

WHAT AM I TRYING TO DO: Basically, I am trying to represent a visual tree representation of an xml document that is rendered on the other Jpanel. When I select node on this rendered xml document, I want to add that xml node onto the visual tree. So essentially, the rendered componenet and the visual tree componenent share the same xml file/variable.

THE PROBLEM (I am open to alternate suggestions) :

I have a visual tree generated by the following method using org.apache.xerces.parsers.SAXParser.

It reads an xml file and returns the scrollPane component to be rendered on screen.

I need to be able to add or remove nodes and edit. So when I click a button, it will add a node to the visual tree. However, I think there needs to be some event listener when the xml file has been updated to quickly draw the tree. This might be inefficient (?) because it requires redrawing the tree everytime xml file change event happens?

private static Component createTree() {
         DefaultMutableTreeNode top = new DefaultMutableTreeNode("test"));

         SAXTreeBuilder saxTree = new SAXTreeBuilder(top); 

         try {             
             SAXParser saxParser = new SAXParser();
             saxParser.setContentHandler(saxTree);
             saxParser.parse(new InputSource(new FileInputStream("test1.xml")));
         }catch(Exception ex){
             ex.printStackTrace();
             top.add(new DefaultMutableTreeNode(ex.getMessage()));
         }

         JTree tree = new JTree(saxTree.getTree()); 
         JScrollPane scrollPane = new JScrollPane(tree);

        return scrollPane;
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T21:38:47+00:00Added an answer on May 20, 2026 at 9:38 pm

    First store the modification time of an XML file in a temporary variable while drawing the tree for the first time then Use a thread or TimerTask to keep track of the modification time ,if there is any change in modification time compared to temporary variable that means XML file is modified.call your tree view generation code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a big problem that a recursive treeview doesn't update any childs if
UPDATE: To clarify a generic error catcher that catches 404's doesn't have enough granularity
I have a database entry that I need to update. This method obviously doesn't
1.The window is flashing while repainting. How can I eliminate that? Using the update
[Update]: my initial example doesn't reflect my problem. Updated the sample, hopfully it is
This doesn't work: UPDATE customers SET firstname=John AND lastname=Smith WHERE id=1;
SQL Server doesn't support the SELECT FOR UPDATE syntax, which is used by NHibernate
My customer doesn't want a database but would prefer to update their data in
Update: This does work, I was being stupid :( i have the following extension
My code does not update the thread field. It is null. Anyone have any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.