1

重複の可能性:
Matrix into JTable

この機能に問題があるようです。jTable のモデルを作成しましたが、必要な値が得られません。コードは次のとおりです。

public class InsertMatToJTable extends AbstractTableModel{
String titre[] = {"age real", "sex real", "chest real", "resting_blood_pressure real",  "serum_cholestoral real","fasting_blood_sugar real","resting_electrocardiographic_results real","maximum_heart_rate_achieved real","exercise_induced_angina real","oldpeak real","slope real","number_of_major_vessels real","thal real", "class"};
    String line;
    float mat[][]= new float[370][13];
    float matrice_normalise[][]=new float[270][13];;
    int i = 1,j=1;
    Vector data;
public void InsertMatToJTable()
    {data= new Vector();
 try {
              FileInputStream fis = new FileInputStream("fichier.txt");
              BufferedReader br = new BufferedReader(new InputStreamReader(fis));

                while ((line = br.readLine()) != null) {
                            StringTokenizer st1 = new StringTokenizer(line, " ");
                            while (st1.hasMoreTokens())
                            {mat[i][j]=Float.valueOf(st1.nextToken()).floatValue(); 
                                                        j++;
                                                       if (j==13) {i++;j=1;}
                            }  

             }
             br.close();
         }catch(Exception e) {
                    e.printStackTrace();}

         Normalisation norm = new Normalisation(mat);

   // for(i=0;i<270;i++)
    //{for(j=0; j<14;j++)
    //{matrice_normalise[i][j]=norm.mat_normalised[i][j];
    //}
      matrice_normalise=norm.mat_normalised;


    }

@Override
public int getRowCount() {
    return 270;
}

@Override
public int getColumnCount() {
    return 13;
}

@Override
 public Object getValueAt(int rowIndex, int columnIndex) {
    return matrice_normalise[rowIndex][columnIndex];
}



public String getColumnName(int columnIndex) {
    return titre[columnIndex];

}
    }

テキストファイルの読み込みが行われます。そのmatrice_normalise=norm.mat_normalised;部分も機能します。私はそれらを互いに別々にテストしましたが、それらは機能しました。

ただし、テーブルには 0.0 が入力されており、 から値を取得していませんmatrice_normalise

4

0 に答える 0