0
I created a program that has a for, this for generates different values, what I need is to print the values in a JTextArea
as 8 values are generated. I did the following:
int tp=2;
int pop[][] = new int[tp][8];
Random ran = new Random();
for(int i=0; i<tp; i++){
String texto="";
for(int j=0; j<8; j++){
int valor = ran.nextInt(2);
pop[i][j] = valor;
texto += valor+", ";
}
txtArea.setText(txtArea.getText()+"\n"+"Valor: "+texto);
}
Theoretically should go setting the value in JTextArea
, but that doesn’t happen.
I don’t know how to solve this problem.
What is this matrix
pop
?– Victor Stafusa
This matrix is where I will store the 8 values, the number of rows of it is "tp" and the number of column 8
– Magno
Please add a [mcve] because this code has some variables that are not even shown their types.
– user28595
If the goal is to update the component with the loop still running, you will need Swingworker. Take an example: https://answall.com/a/248098/28595
– user28595