Mozart did not like the flute and when he was asked what he considers worse, he answered two flutes!
Finale I have the the program working. I have tested the application many times and everything works just fine. I have to take care of some esthetical things.... and done.
Probably the underlaying mistake of the program is that I did not put the GUI stuff into the top class. I have two waitloops taking care of the GUI management, and one in a new created thread. (PK, I did synchronize some method concerning your remark)
private void waitloop() {
wl = new Waitloop();
wl.start();
cont.setstartFlag(false);
cont.selectonoff(true);
start=false;
do { } while (!start); // wait for start button
int trc = cont.gettrackNumb(); // read out the track number
mainSoundblock(trc);
}
class Waitloop extends Thread {
public Waitloop() {
cnt++; // the thread counter
System.out.println("count wait thread " + cnt); // to see what it is looping
}
public void run() {
cont.setstartFlag(false);
do {
} while (!cont.getstartFlag()); // read the start button
start=true;
System.out.println("exit thread " + cnt);
}
}
private void mainSoundblock(int trck) {
cont.ed.resetFbo();
cont.setescFlag(false);
trig=false; exit=false;
if (trck==1 && !cont.getescFlag()) {
Soundblock1();
cont.settrackNumb(trck);
trck=2;
}
if (trck==2 && !cont.getescFlag()) {
Soundblock2();
cont.settrackNumb(trck);
trck=3;
}
if (trck==3 && !cont.getescFlag()) {
Soundblock3();
cont.settrackNumb(trck);
trck=4;
}
if (trck==4 && !cont.getescFlag()) {
Soundblock4();
cont.settrackNumb(trck);
trck=5;
}
....... etc until 12
System.out.println(" end of sound block " );
cont.setescFlag(false);
// cont.ed.closeFbo1();
cont.stopclk();
cont.ed.resetFbo();
waitloop();
}
Sure next programming project I should design differently and I will try to get rid of those un-elegant cpu consuming loops.
Two more questions
1) when appending text into a JTextArea, how could I keep the new text on sight at the screen (the new appended text scrolls down and disappears)?
2) Before going out of the application, at the very last moment, I would like to clean up some things (clossing drivers etc.). I am using the standard
window.setDefaultCloseOperation( JFrame.EXIT_ON_CLOSE );
to exit.