JList doesn't constantly refresh

R

ravxm

I'm having a problem updating my jLists. I'm trying to update it using
the jList.setListData(array) while in a loop so that it's constantly
updated. Any suggestions or strategies are greatly appreciated. Thanks

private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {
int number2=4;
double arrivalrate2=.000003;
do{
if(Math.random()<arrivalrate2)
{
Random rand2=new Random();
number2=rand2.nextInt(2);
int lanenumberassigned;
Auto auto=getAuto();
LaneStatusRunnable lsrunnable=new
LaneStatusRunnable(lane1queue,lane2queue,lane3queue,lane4queue,lane5queue,lane6queue);
lanenumberassigned=lsrunnable.getLaneAssignment();
switch(lanenumberassigned)
{
case 1:
lane1queue.add(auto);
jList1.setListData(lane1queue.toArray());
System.out.println("Lane 1 assigned");
break;
case 2:
lane2queue.add(auto);
jList2.setListData(lane2queue.toArray());
System.out.println("Lane 2 assigned");
break;
case 3:
lane3queue.add(auto);
jList3.setListData(lane3queue.toArray());
System.out.println("Lane 3 assigned");
break;
case 4:
lane4queue.add(auto);
jList4.setListData(lane4queue.toArray());
System.out.println("Lane 4 assigned");
break;
case 5:
lane5queue.add(auto);
jList5.setListData(lane5queue.toArray());
System.out.println("Lane 5 assigned");
break;
case 6:
lane6queue.add(auto);
jList6.setListData(lane6queue.toArray());
System.out.println("Lane 6 assigned");
break;

default:
System.out.println("Error at lanenumberassigned
switch");
break;

}
}
}while(number2!=5);
}
 
A

Andrew Thompson

ravxm said:
I'm having a problem updating my jLists. I'm trying to update it using
the jList.setListData(array) while in a loop so that it's constantly
updated.

The code is probably blocking the EDT.
Any suggestions or strategies are greatly appreciated.

Don't (block the EDT).

Andrew T.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top