private class Lytterklasse implements ActionListener{
public void actionPerformed(ActionEvent e) {
JFileChooser chooser = new JFileChooser();
FileNameExtensionFilter filter = new FileNameExtensionFilter(
"Sudoku Tekstfiler", "txt");
chooser.setFileFilter(filter);
int returnVal = chooser.showOpenDial开发者_运维问答og(getParent());
String filnavn=chooser.getName();
In innfil=new In(filnavn);
int type=innfil.inInt();
int lengdeBoks=innfil.inInt();
int breddeBoks=innfil.inInt();
for(int i=0;i<type*type;i++){
tallene[i]=innfil.nextChar();
}
}
}
Why does this crash on me? I cant figure it out. Please help!
From your code it's not clear, what the In
class is. Also you're accessing the tallene
array which is neither declared nor initialized in your code. Maybe a
tallene = new char[type*type];
before the for
loop could solve your problem. For a better answer, we would need more details (especially what kind of 'crash' you're experiencing ...)
Doh, sorry to bother you. Im too tired.
I went straight from the filechooser without setting a File=chooser.getSelectedfile();
sorry :O
精彩评论