I have two different and independent JFrame
windows:
DataFrame
GraphFrame
The first one is for the user to manipulate, with the input of different values and patterns to display on a graph presented in 2). The 1) sends specific values to 2) (array with doubles) so that "GraphFrame" can create the graph.
I invoke the "main " method from GraphFrame in the "main" method of DataFrame so that they both run at the same time and are both visible during the whole process.
I want these frames to be completely independent, which means that the mission for 1) is to send values and the mission for 2) is to check when values are recieved and then create the graph.
I also prefer to keep most of the methods private, so that they can't be accessed from external sources.
My problem, is that I don't know which is the best way to implement this data exchange. What is the best way for Frame 2) keep "listening" for the values it needs to recieve?
Should I create getters/setters on 2) and with the help of an Observer https://sourcemaking.com/design_patterns/observer ?
Or should I use threads?
Or even the creation of a traditional loop that keeps waiting for values, like:
while(array.isEmpty()) {
//stuck here
}
//create the graph from the values in array
At the moment I am receiving the values in 2) from setter methods, but I am uncapable, so far, of performing the code I desire only after I get the values.
What do you think is the best way to implement this?
P.S.: Should I consider not invoking GraphFrame
main from DataFrame
and run these 2 separately?