• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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.


 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic