FileChooser problem
in
Programming Questions
•
3 years ago
Hello all :)
I'm using a Swing FileChooser in my program, but it doesn't work every time.
Sometimes, it works very fine, and sometimes, ONLY the border of the Choose window is drawn, and the program is blocked without any error. If it happend, I can't do anything, even the close button doesn't work.
- // CLASS VARIABLE ( of my class "Main extends PApplet")
- // create a file chooser
- JFileChooser fc;
- // IN setup()
- // set system look and feel
- try {
- UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
- } catch (Exception e) {
- e.printStackTrace();
- }
- fc = new JFileChooser();
- // IN KEY EVENT
- if(key=='o'){
- int returnVal = fc.showOpenDialog(getParent());
- if (returnVal == JFileChooser.APPROVE_OPTION) {
- File file = fc.getSelectedFile();
- if (file.getName().endsWith("mov")) {
- // I DO SOMETHING
- } else {
- String lines[] = loadStrings(file);
- for (int i = 0; i < lines.length; i++) {
- println(lines[i]);
- }
- }
- } else {
- println("Open command cancelled by user.");
- }
- }
So, I'd like to know from where come this problem,
how I can eliminate it OR how I can detect that there is an error in order to prevent total freezing.
thanks :)
1