I’m trying to assemble a graphical representation of a MIDI sequence, and I’d like a vertical line to move across the panel horizontally as the sequence plays, reflecting the actual position in the sequence. I know that I should use something like getTickPosition() to provide the location of the vertical line.
But how do I fire off these events so that the vertical line knows to redraw itself? Do I create a special listener that the ticks somehow trigger?
Establish a Swing
Timerto check and update the tick position every NN milliseconds.Sure there is. But the point is that all GUI updates should happen on the EDT. By invoking them from a Swing
Timer, they are. Also, the MIDI timer is for the use of MIDI API/System, let it do what it does undisturbed, and report back the relevant information when checked from the SwingTimer.Also, given the nature of the UI component, look to a
JProgressBaras seen in the upper right of this GUI.Update
I adapted the source seen on the Java Sound WIKI into an SSCCE of this approach.