Hey,
Right now I’m creating an application with Swing and Processing in separate windows. I’ve verified the Processing methods I call are functional, so I believe the following issues occur because Processing and Swing occur on different threads(?) I’m pretty new to the concept of threads, so I’m not sure essentially how to get them to “sync” if that makes sense.
For example, I have an actionListener for a ComboBox that adds another graph to the processing sketch. However, when this code is ran from this actionListener:
public void actionPerformed(ActionEvent e) {
JComboBox<String> tmp = (JComboBox<String>) e.getSource();
windowIndex = tmp.getSelectedIndex();
pWindows.setGraph(windowIndex);
}
funky things start happening due to calling the setGraph function, which (I’ve verified works on the Processing side) essentially switches the Processing sketch to display the new graph. However, because of the interactions between Processing and Swing, the application goes from a nice graph to
I believe I somehow need to cause a thread or something to wait, but since I’m not sure exactly how the Dispatch Thread really works especially with other threads so I’m not sure what approach I should use on either window to get the transition to work smoothly.
If you want to see the code I have it here but it’s a lot to sort through and I don’t think it really is needed.
Thanks!