I am trying to get a JFileChooser to work in my JOGL applet with limited success. The file chooser appears on the screen ok but during folder navigation, selection or moving the file chooser window around, various exceptions can be thrown…
Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException
at javax.swing.plaf.basic.BasicListUI.updateHorizontalLayoutState(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source)
at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
etc.
OR
Exception occurred during event dispatching:
java.lang.IndexOutOfBoundsException: Invalid index
at javax.swing.DefaultRowSorter.convertRowIndexToModel(Unknown Source)
at sun.swing.FilePane$SortableListModel.getElementAt(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.paintCell(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.paintImpl(Unknown Source)
at javax.swing.plaf.basic.BasicListUI.paint(Unknown Source)
etc.
The applet is a java.applet.Applet and I create a GLCanvas (javax.media.opengl.GLCanvas) which is created like this…
In the Applet init() method I have…
setLayout(new BorderLayout());
GLCanvas canvas = new GLCanvas();
listener = new listener(); // my own class which extends MouseAdapter and implements GLEventListener
canvas.addGLEventListener(listener);
Dimension size = getSize();
canvas.setSize(size);
add(canvas, BorderLayout.CENTER);
And then to get a JFileChooser I do this…
JFileChooser fc = new JFileChooser();
fc.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
int returnVal = fc.showSaveDialog(canvas);
Anyone know what causes the thrown exceptions and how do I fix them?
Is there a better way of doing this?
Thanks!