File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes Setting a TextArea to show contents of file. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Setting a TextArea to show contents of file." Watch "Setting a TextArea to show contents of file." New topic
Author

Setting a TextArea to show contents of file.

wasif akbar
Greenhorn

Joined: May 02, 2001
Posts: 11
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.
ming fan
Greenhorn

Joined: Nov 15, 2000
Posts: 21
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.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Setting a TextArea to show contents of file.
 
Similar Threads
Servlet Life Cycle
Renamae browse button of inputFile
VTD XML buffer re-use
input type=file question
Basic GUI help