ボタンクリックで実行される次のtry catchブロックがあります。txtファイルからjListに項目を追加しようとしています
try {
//picking up the file I want to read in
BufferedReader in = new BufferedReader(new FileReader("C:\\users\\me\\desktop\\blah.txt"));
String line;
try {
//read through the file until there is nothing left and add each line to list
while((line = in.readLine()) != null){
jList1.add(line, jList1);
}
} catch (IOException ex) {
Logger.getLogger(Frame2.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (FileNotFoundException ex) {
Logger.getLogger(Frame2.class.getName()).log(Level.SEVERE, null, ex);
}
私はので、私は何かが右に働いている成功しSystem.out.println(line)
を知ることができます。私は、テキストファイルからの行をリストに取り込むことができません。上記のコードは私に教えてくれるcannot add containers parent to self.
詳細を調べようとするともっと混乱してしまいます。私はいくつかの場所に出くわしました.JListsはこれよりも複雑です。
個人的なデバッガ:-) 'FileReade'は' FileReader'でなければなりません – mKorbel
チュートリアルを読んでください。これは基本的なものです。 – Moonbeam
[TXTファイルをJListに読み込む方法は?](http://stackoverflow.com/questions/5930353/how-to-load-a-txt-file-into-a-jlist) –