I am creating a live graphing application, using a library called 'LiveGraph', which I stumbled upon. Essentially, the LiveGraph application is a GUI that keeps on reading from a text file with data, and updates the corresponding graph.
Here is a snippet of the code I have (explanations below:
for (VisualDisplay vd : visDisplayElements) {
vd.display();
System.out.println("Done executing.");
}
while (!dcm.done) {
String packet = dcm.run();
HashMap<String, Integer> dataMap = initializeMap (packet, config.delimiter, config.colNames);
for (VisualDisplay element : visDisplayElements) {
element.receivedDataSet(dataMap);
}
}
The first for loop essentially goes through the list of graphs and loads up the GUI for each of them. The while loop afterwards essentially keeps polling forever for data through the network.
Now here's the scenario: When I am only displaying the graphs (i.e., if I comment out the while loop), the graphs display and open up (but obviously don't display anything because nothing is polling). However, with all the code as shown below, the GUI windows for the graphs open up, but turn out completely gray, with no content. If I try resizing or interacting with them in any way, the application freezes, and I have to force quit.
I'm narrowed this down to the issue that threading is somehow a problem here. The while-loop will keep running forever, and maybe the GUI's will not run properly due to that. I am looking for a solution to this, that maybe involves threading. I'm tried a few basic things, such as running the display and polling each as separate threads, but I was getting nowhere.