Forums Register Login

Setting a TextArea to show contents of file.

+Pie Number of slices to send: Send
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.
+Pie Number of slices to send: Send
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.


Acetylsalicylic acid is aspirin. This could be handy too:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1737 times.
Similar Threads
Basic GUI help
input type=file question
Servlet Life Cycle
Renamae browse button of inputFile
VTD XML buffer re-use
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 17:54:18.