public void importEmitter() {
		chooser.setDialogTitle("Open");
		int resp = chooser.showOpenDialog(this);
		if (resp == JFileChooser.APPROVE_OPTION) {
			File file = chooser.getSelectedFile();
			File path = file.getParentFile();
			
			try {
				final ConfigurableEmitter emitter = ParticleIO.loadEmitter(file);
				
				
				if (emitter.getImageName() != null) {
					File possible = new File(path, emitter.getImageName());
					
					if (possible.exists()) {
						emitter.setImageName(possible.getAbsolutePath());
					} else {
						chooser.setDialogTitle("Locate the image: "+emitter.getImageName());
						resp = chooser.showOpenDialog(this);
						FileFilter filter = new FileFilter() {
							public boolean accept(File f) {
								if (f.isDirectory()) {
									return true;
								}
								
								return (f.getName().equals(emitter.getImageName()));
							}
	
							public String getDescription() {
								return emitter.getImageName();
							}
						};
						chooser.addChoosableFileFilter(filter);
						if (resp == JFileChooser.APPROVE_OPTION) {
							File image = chooser.getSelectedFile();
							emitter.setImageName(image.getAbsolutePath());
							path = image.getParentFile();
						}
						chooser.resetChoosableFileFilters();
						chooser.addChoosableFileFilter(xmlFileFilter);
					}
				}
				
				addEmitter(emitter);
				emitters.setSelected(emitter);
			} catch (IOException e) {
				Log.error(e);
				JOptionPane.showMessageDialog(this, e.getMessage());
			}
		}
	}
public void importEmitter ( ) { chooser . setDialogTitle ( "Open" ) ; int resp = chooser . showOpenDialog ( this ) ; if ( resp == JFileChooser . APPROVE_OPTION ) { File file = chooser . getSelectedFile ( ) ; File path = file . getParentFile ( ) ; try { final ConfigurableEmitter emitter = ParticleIO . loadEmitter ( file ) ; if ( emitter . getImageName ( ) != null ) { File possible = new File ( path , emitter . getImageName ( ) ) ; if ( possible . exists ( ) ) { emitter . setImageName ( possible . getAbsolutePath ( ) ) ; } else { chooser . setDialogTitle ( "Locate the image: " + emitter . getImageName ( ) ) ; resp = chooser . showOpenDialog ( this ) ; FileFilter filter = new FileFilter ( ) { public boolean accept ( File f ) { if ( f . isDirectory ( ) ) { return true ; } return ( f . getName ( ) . equals ( emitter . getImageName ( ) ) ) ; } public String getDescription ( ) { return emitter . getImageName ( ) ; } } ; chooser . addChoosableFileFilter ( filter ) ; if ( resp == JFileChooser . APPROVE_OPTION ) { File image = chooser . getSelectedFile ( ) ; emitter . setImageName ( image . getAbsolutePath ( ) ) ; path = image . getParentFile ( ) ; } chooser . resetChoosableFileFilters ( ) ; chooser . addChoosableFileFilter ( xmlFileFilter ) ; } } addEmitter ( emitter ) ; emitters . setSelected ( emitter ) ; } catch ( IOException e ) { Log . error ( e ) ; JOptionPane . showMessageDialog ( this , e . getMessage ( ) ) ; } } }
Import an emitter XML file