Question

I have a infinitive loop program enters the loop when a button clicked and this button makes CONFLAG=true and I have another button and this makes CONFLAG=false I want to enter the loop when button 1 clicked and exit when button2 clicked, also I have another question while in this loop program must change jLabel3's text but it stucks and just do Regenerate Thank you

while(true)
    {
        Regenerate((GENNUM-200));
        Arrays.sort(gend,descTime);
        jLabel3.setText(Integer.toString(gend[1].time));
        if(CONFLAG==false)
            break;
    }

No correct solution

OTHER TIPS

I have a infinitive loop program enters the loop when a button clicked

Then you code is executing on the Event Dispatch Thread and you a preventing the GUI from responding to events or repainting itself until the code is finished executing.

You need to create a separate Thread to execute the code in this loop. The easiest way to do this is to use a SwingWorker then you can publish intermediate results to display on your label. Read the section from the Swing tutorial on Concurrency for more information and examples.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top