Bonjour
je veux lire à partir d`un fichier son contenu qui est sous forme d`un entier par ligne jusqu`à 81,et puis afficher ce contenu dans une interface sous forme de tableau de JLabel de deux dimensions.mon code m`affiche une interface vide que je ne sais pas pourquoi. j`ai vraiment besoin d`une réponse.merci d`avance
public class Interface extends JFrame {
//public Grid gridd ;
static JLabel cell[][]=new JLabel [9][9];
int i;
int j;
int k=0;
RandomAccessFile rd;
public Interface() throws Exception
{
setSize(150,300);
setTitle("SUDOKU");
setLocation(250,500);
setBackground (Color.yellow);
getContentPane().setLayout(new FlowLayout());
String val[] = getValues();
if(val.length!=81)
{
System.exit(0);
}
for(int h=0;h<81;h++)
{
if(Integer.parseInt(val[h])<0);
{
System.exit(0);
}
}
for (int i=0; i<9; i++)
{
// read() lit le prochain caractère du flux (retourne un int car c'est sur 16 bits).
//Utilise read(char cbuf[], int off, int len).
for(int j=0;j<9;j++)
{ //les cellules donnees
//cells[i][j]=ch-(int)'0';
// cell[i][j]=new JLabel("+ch-(int)'0'");
if(val[k]!="0")
{
cell[i][j].setText(val[k]);
}
else
{cell[i][j].setText("");}
k++;
add(cell[i][j]);
}
}
setDefaultCloseOperation(EXIT_ON_CLOSE);
setVisible(true);
}
String[] getValues() throws Exception
{
rd = new RandomAccessFile("C:\\testGrid.txt", "r");
String vals[]=new String [81];
// BufferedReader entree = new BufferedReader (new FileReader ("C:\\testGrid.txt") );
//on se positionne à la dernière ligne
rd.seek(0);
for(int o=0;o<81;o++)
{
vals[o] = rd.readLine();
}
rd.close();
return vals;
}
}