} catch (IOException e) { Log.log(Log.LEVEL_ERROR, MODULE, "Exception while trying to read state"); Log.logException(Log.LEVEL_ERROR, MODULE, e); } catch (ClassNotFoundException e) { Log.log(Log.LEVEL_ERROR, MODULE, "Exception while trying to read state (probably a version mismatch)"); Log.logException(Log.LEVEL_ERROR, MODULE, e);
	private void openState(String fileToOpen) {		JFileChooser fc = null;		if (null == fileToOpen) {			fc = new JFileChooser();			fc.setAcceptAllFileFilterUsed(false);			fc.setFileFilter(galleryFileFilter);			int returnVal = fc.showOpenDialog(this);			if (returnVal != JFileChooser.APPROVE_OPTION) {				return;			}			// Remember the file			lastOpenedFile = fc.getSelectedFile();			Log.log(Log.LEVEL_INFO, MODULE,					"Opening state from file " + fc.getSelectedFile().getPath());		} else {			lastOpenedFile = new File(fileToOpen);			Log.log(Log.LEVEL_INFO, MODULE,					"Opening state from file " + fileToOpen);		}		// Before we change galleries, ask them if they want to save.		int response = saveOnPermission("OK_toSaveBeforeClose");		if (JOptionPane.CANCEL_OPTION == response) {			return;		}		new Thread() {			public void run() {				try {					getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));					setInProgress(true);					ObjIn in = new ObjIn(new BufferedReader(new FileReader(lastOpenedFile)));					Gallery[] galleryArray = (Gallery[]) in.readObject();					DefaultComboBoxModel newGalleries = new DefaultComboBoxModel();					Gallery selectGallery = null;					for (int i = 0; i < galleryArray.length; i++) {						Gallery gallery = galleryArray[i];						newGalleries.addElement(gallery);						//galleryArray[i].checkTransients();						//gallery.addListDataListener(MainFrame.this);						ArrayList pictures = gallery.getAllPictures();						preloadThumbnails(pictures.iterator());						if (pictures.size() > 0) {							gallery.doFetchAlbums(jStatusBar, false);							if (selectGallery == null) {								selectGallery = gallery;							}						}					}					saveMRUItem(lastOpenedFile);					setGalleries(newGalleries);					if (selectGallery == null && newGalleries.getSize() > 0) {						selectGallery = (Gallery) newGalleries.getElementAt(0);					}					if (selectGallery != null) {						jGalleryCombo.setSelectedItem(selectGallery);					}					setInProgress(false);				} catch (IOException e) {					Log.log(Log.LEVEL_ERROR, MODULE, "Exception while trying to read state");					Log.logException(Log.LEVEL_ERROR, MODULE, e);				} catch (ClassNotFoundException e) {					Log.log(Log.LEVEL_ERROR, MODULE, "Exception while trying to read state (probably a version mismatch)");					Log.logException(Log.LEVEL_ERROR, MODULE, e);				} catch (NoClassDefFoundError e) {					Log.log(Log.LEVEL_ERROR, MODULE, "JSX not installed, can't read state...");				} finally {					getContentPane().setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));				}			}		}.start();	}