• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Setting a TextArea to show contents of file.

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The application I working on allows you to parse thru xml files. It looks for certain tags within the xmls and then writes out the value for the "Name" attribute of that tag to a file. On my gui, I have a textfield, a textarea and two buttons, one button to browse for the xml file and one called parse. When I parse, all of objects that I am parsing for get written to a file that is created. Basically what I want is for the user to be able view the contents of the file as it is being generated or as soon as it is generated in the textarea on my gui. What I don't want to do is create another button called "View File" and then when you click on it, the file gets opened in the textarea. I want the contents to be displayed in the textarea as soon as the file has been parsed or while it is being parsed.
Any help would be great. Sample code would be even better. The gui is mostly awt components except for the filechooser when I browse.
 
Greenhorn
Posts: 21
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think you have several options:
1. Change your parsing code, so when it's parsing, it also appends whatever you parsed to the text area.
2. Do the parsing, when it's done and the file is created, trigger some kind of parsing done event and make your text area listen for that event so it knows when to read the file in.
3. After you start to parse, open a file input stream to the file you created and keeps reading and appends the input to the text area, but for this you can't close your input stream when you read the end of line (null in java input stream) since your read speed maybe faster then your parse speed, so you need some kind of customized end of line symbol to indicate the file is completed (like put "END" at the end of file, etc.)
I personally preferred the second way. Hope this helps.

Originally posted by wasif akbar:
The application I working on allows you to parse thru xml files. It looks for certain tags within the xmls and then writes out the value for the "Name" attribute of that tag to a file. On my gui, I have a textfield, a textarea and two buttons, one button to browse for the xml file and one called parse. When I parse, all of objects that I am parsing for get written to a file that is created. Basically what I want is for the user to be able view the contents of the file as it is being generated or as soon as it is generated in the textarea on my gui. What I don't want to do is create another button called "View File" and then when you click on it, the file gets opened in the textarea. I want the contents to be displayed in the textarea as soon as the file has been parsed or while it is being parsed.
Any help would be great. Sample code would be even better. The gui is mostly awt components except for the filechooser when I browse.


 
Opportunity is missed by most people because it is dressed in overalls and looks like work - Edison. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic