Related to my other thread, I now need to do something with the files I’ve created. I’ve stuck the list of file names in a datset, and populated a table (instead of a dropdown list, but the principle remains the same). As the operator arrows down through the table, the files should appear in a window. The files are text files, but have odd extensions, so I couldn’t get them to work with doc viewer, but your “Text Area” input box works great for what I want. Here’s what I’m doing:
I highlight a row in the table. Based on a propertyChange event, I go grab the file the row is pointing to, and rip through the file line by line like this:
if event.propertyName == 'selectedRow': import os tFile = event.source.SelectedValue a_dir = 'C:\\Import\\Files' tFile = a_dir + "\\" + tFile event.source.parent.getComponent('Text Area').text = '' t_readFile = open(tFile, 'r') for line in t_readFile.readlines(): event.source.parent.getComponent('Text Area').text = event.source.parent.getComponent('Text Area').text + line
Is there a better way of writing to the text area than (quasi code) “TextArea.txt = TextArea.txt + line” ? I tried a few variations of readlines(), but I don’t quite understand what a text area actually is I guess.
As I rip through each line, I’d like to affect certain characters based on operator input. For instance, if they are looking for the word “START”, I would like to use HTML coding to bolden and highlight each occurance. Does your text area box support this?
Is there a better way besides a text area box to do what I’m trying to do? Perhaps a java swing component? I’d like to have ultimate control over how the text is displayed if possible.