I am using Java FX textarea and using it as to provide information for the steps going on.
Steps are as follows. Copy a file. Delete old file. Copy New File. and then copy some properties from old to new file.
This whole step starts when a button is clicked.
The problem I am facing is that text area is not being updated as soon as I use the append command.
The append command adds data and when the function terminates, I get all the text together. I want the text area to be updated as I call the function.
In my program, the copy file operation, takes some time as it is a big file. So in the start I display message that the operation has started. and at the end of operation I want to display the operation has ended.
But the text area displays all these texts all together.
I read in oracle forum, that text area in FX uses a single thread hence wont display anything until the whole process is complete.
Article : https://community.oracle.com/message/9938117#9938117
Can any one suggest what should I do.?
New Edit
Okay on Button Click I am calling a function which executes the following methods.
public void executeCmds(){
createTempDirectory();
copyConfigPropetiesFileValues();
copyConfigProperties();
copyYMLFile();
copyYMLFileProperties();
stopTomcatServer();
deleteOldWar();
copyNewWar();
startTomcatServer();
copyOldConfigFile();
copyOldYMLFile();
}
Now Each of the function is a process, which should be executed sequentially. And after each step is completed I want to update the GUI text area with a success message that this is complete.
For the I am using method as follows:
public void createTempDirectory(){
//Creating temporary directory for copying property files
status_text_area.appendText("Trying to create a temp directory \n");
File tempDir= new File(tomcat_path.getText()+filePath.path_to_temp_directory);
if(!tempDir.exists())
tempDir.mkdirs();
status_text_area.appendText("Created Temp directory to copy Config Files \n");
}
and same is with other functions. The copyWar file function and delete warfile function take time as it copies 130 MB file from a location to other.
So I want the textarea to be displayed as, 1. Started copying file and after some time
- FIle copied.
But the issue is , the text area does not populate at all, until all the functions are executed.
If I try to execute these via threads, then the order of execution is not guranteed. Please Help