Java Code Examples for javax.swing.JFileChooser.addPropertyChangeListener()

The following are Jave code examples for showing how to use addPropertyChangeListener() of the javax.swing.JFileChooser class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: incubator-netbeans   File: ProjectChooserAccessory.java   Source Code and License Vote up 6 votes
/** Creates new form ProjectChooserAccessory */
public ProjectChooserAccessory(JFileChooser chooser, boolean isOpenSubprojects) {
    initComponents();

    modelUpdater = new ModelUpdater();
    //#98080
    RP = new RequestProcessor(ModelUpdater.class.getName(), 1);
    RP2 = new RequestProcessor(ModelUpdater.class.getName(), 1);
    updateSubprojectsTask = RP.create(modelUpdater);
    updateSubprojectsTask.setPriority( Thread.MIN_PRIORITY );

    // Listen on the subproject checkbox to change the option accordingly
    jCheckBoxSubprojects.setSelected( isOpenSubprojects );
    jCheckBoxSubprojects.addActionListener( this );

    // Listen on the chooser to update the Accessory
    chooser.addPropertyChangeListener( this );

    // Set default list model for the subprojects list
    jListSubprojects.setModel( new DefaultListModel() );

    // Disable the Accessory. JFileChooser does not select a file
    // by default
    setAccessoryEnablement( false, 0 );
}
 
Example 2
Project: jaer   File: SingleCameraCalibration.java   Source Code and License Vote up 6 votes
synchronized public void doLoadCalibration() {
    final JFileChooser j = new JFileChooser();
    j.setCurrentDirectory(new File(dirPath));
    j.setApproveButtonText("Select folder");
    j.setDialogTitle("Select a folder that has XML files storing calibration");
    j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
    j.setApproveButtonText("Select folder");
    j.setApproveButtonToolTipText("Only enabled for a folder that has cameraMatrix.xml and distortionCoefs.xml");
    setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
    j.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY, new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent pce) {
            setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
        }
    });
    int ret = j.showOpenDialog(null);
    if (ret != JFileChooser.APPROVE_OPTION) {
        return;
    }
    dirPath = j.getSelectedFile().getPath();
    putString("dirPath", dirPath);

    loadCalibration();
}
 
Example 3
Project: jaer   File: SingleOrStereoCameraCalibration.java   Source Code and License Vote up 6 votes
synchronized public void doLoadCalibration() {
	final JFileChooser j = new JFileChooser();
	j.setCurrentDirectory(new File(dirPath));
	j.setApproveButtonText("Select folder");
	j.setDialogTitle("Select a folder that has XML files storing calibration");
	j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
	j.setApproveButtonText("Select folder");
	j.setApproveButtonToolTipText("Only enabled for a folder that has cameraMatrix.xml and distortionCoefs.xml");
	setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
	j.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY, new PropertyChangeListener() {
		@Override
		public void propertyChange(PropertyChangeEvent pce) {
			setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
		}
	});
	int ret = j.showOpenDialog(null);
	if (ret != JFileChooser.APPROVE_OPTION) {
		return;
	}
	dirPath = j.getSelectedFile().getPath();
	putString("dirPath", dirPath);

	loadCalibration();
}
 
Example 4
Project: jaer   File: StereoCalibrationDualViewFilter.java   Source Code and License Vote up 6 votes
synchronized public void doLoadCalibration() {
	final JFileChooser j = new JFileChooser();
	j.setCurrentDirectory(new File(dirPath));
	j.setApproveButtonText("Select folder");
	j.setDialogTitle("Select a folder that has XML files storing calibration");
	j.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); // let user specify a base filename
	j.setApproveButtonText("Select folder");
	j.setApproveButtonToolTipText("Only enabled for a folder that has cameraMatrix.xml and distortionCoefs.xml");
	setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
	j.addPropertyChangeListener(JFileChooser.DIRECTORY_CHANGED_PROPERTY, new PropertyChangeListener() {
		@Override
		public void propertyChange(PropertyChangeEvent pce) {
			setButtonState(j, j.getApproveButtonText(), calibrationExists(j.getCurrentDirectory().getPath()));
		}
	});
	int ret = j.showOpenDialog(null);
	if (ret != JFileChooser.APPROVE_OPTION) {
		return;
	}
	dirPath = j.getSelectedFile().getPath();
	putString("dirPath", dirPath);

	loadCalibration();
}
 
Example 5
Project: incubator-netbeans   File: AntArtifactChooser.java   Source Code and License Vote up 5 votes
/** Creates new form JarArtifactChooser */
public AntArtifactChooser( String[] artifactTypes, JFileChooser chooser ) {
    this.artifactTypes = artifactTypes;
    
    initComponents();
    jListArtifacts.setModel( new DefaultListModel() );
    chooser.addPropertyChangeListener( this );
}
 
Example 6
Project: jaer   File: MotionViewer.java   Source Code and License Vote up 5 votes
/** adds a keyreleased listener on the JFileChooser FilePane inner classes so that user can use Delete key to delete the file
 * that is presently being shown in the preview window
 * @param chooser the chooser
 * @param preview the data file preview
 */
public FileDeleter(JFileChooser chooser, ChipDataFilePreview preview) {
    this.chooser = chooser;
    this.preview = preview;
    chooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, this);
    Component comp = addDeleteListener(chooser);
}
 
Example 7
Project: Neukoelln_SER316   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 8
Project: smile_1.5.0_java7   File: FileChooser.java   Source Code and License Vote up 4 votes
/**
 * Constructor.
 */
public FilePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(160, 160));
    fc.addPropertyChangeListener(this);
}
 
Example 9
Project: SER316-Dresden   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 10
Project: jaer   File: AEViewer.java   Source Code and License Vote up 4 votes
private void sequenceMenuItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_sequenceMenuItemActionPerformed

            if (evt.getActionCommand().equals("start")) {
                float oldScale = chipCanvas.getScale();
                AESequencerInterface aemonseq = (AESequencerInterface) chip.getHardwareInterface();
                try {
                    if ((aemonseq != null) && (aemonseq instanceof AEMonitorSequencerInterface)) {
                        ((AEMonitorSequencerInterface) aemonseq).stopMonitoringSequencing();
                    }
                } catch (HardwareInterfaceException e) {
                    e.printStackTrace();
                }

                JFileChooser fileChooser = new JFileChooser();
                ChipDataFilePreview preview = new ChipDataFilePreview(fileChooser, chip); // from book swing hacks
                fileChooser.addPropertyChangeListener(preview);
                fileChooser.setAccessory(preview);

                String lastFilePath = prefs.get("AEViewer.lastFile", ""); // getString the last folder

                lastFile = new File(lastFilePath);

                DATFileFilter datFileFilter = new DATFileFilter();
                fileChooser.addChoosableFileFilter(datFileFilter);
                fileChooser.setCurrentDirectory(lastFile); // sets the working directory of the chooser
                //            boolean wasPaused=isPaused();
                //        setPaused(true);
                int retValue = fileChooser.showOpenDialog(this);
                if (retValue == JFileChooser.APPROVE_OPTION) {
                    lastFile = fileChooser.getSelectedFile();
                    if (lastFile != null) {
                        recentFiles.addFile(lastFile);
                    }
                    SwingUtilities.invokeLater(new Runnable() {

                        @Override
                        public void run() {
                            sequenceFile(lastFile);
                        }
                    });
                }
                fileChooser = null;
                //     setPaused(false);
                //            chipCanvas.setScale(oldScale);
            } else if (evt.getActionCommand().equals("stop")) {
                setPlayMode(PlayMode.LIVE);
                stopSequencing();
            }
	}
 
Example 11
Project: jaer   File: AEPlayer.java   Source Code and License Vote up 4 votes
/**
     * Called when user asks to open data file file dialog.
     */
    @Override
    public void openAEInputFileDialog() {
//        try{Thread.currentThread().sleep(200);}catch(InterruptedException e){}
        float oldScale = viewer.chipCanvas.getScale();
        fileChooser = new JFileChooser();
//            new TypeAheadSelector(fileChooser);
        //com.sun.java.plaf.windows.WindowsFileChooserUI;
//            fileChooser.addKeyListener(new KeyAdapter() {
//                public void keyTyped(KeyEvent e){
//                    System.out.println("keycode="+e.getKeyCode());
//                }
//            });
//            System.out.println("fileChooser.getUIClassID()="+fileChooser.getUIClassID());
//            KeyListener[] keyListeners=fileChooser.getKeyListeners();
        ChipDataFilePreview preview = new ChipDataFilePreview(fileChooser, viewer.getChip());
        // from book swing hacks
        new FileDeleter(fileChooser, preview);
        fileChooser.addPropertyChangeListener(preview);
        fileChooser.setAccessory(preview);
        String lastFilePath = AEViewer.prefs.get("AEViewer.lastFile", "");
        // get the last folder
        viewer.lastFile = new File(lastFilePath);
//            fileChooser.setFileFilter(datFileFilter);
        IndexFileFilter indexFileFilter = new IndexFileFilter();
        fileChooser.addChoosableFileFilter(indexFileFilter);
        DATFileFilter datFileFilter = new DATFileFilter();
        fileChooser.addChoosableFileFilter(datFileFilter);
        if (lastFilter == null) {
            fileChooser.setFileFilter(datFileFilter);
        } else {
            fileChooser.setFileFilter(lastFilter);
        }
        fileChooser.setCurrentDirectory(viewer.lastFile);
        // sets the working directory of the chooser
//            boolean wasPaused=isPaused();
        setPaused(true);
        try {
            int retValue = fileChooser.showOpenDialog(viewer);
            if (retValue == JFileChooser.APPROVE_OPTION) {
                lastFilter = fileChooser.getFileFilter();
                try {
                    viewer.lastFile = fileChooser.getSelectedFile();
                    if (viewer.lastFile != null) {
                        viewer.recentFiles.addFile(viewer.lastFile);
                    }
                    startPlayback(viewer.lastFile);
                } catch (IOException fnf) {
                    log.warning(fnf.toString());
                }
            } else {
                preview.showFile(null);
            }
        } catch (GLException e) {
            log.warning(e.toString());
            preview.showFile(null);
        }
        fileChooser = null;
//        viewer.chipCanvas.setScale(oldScale);
        // restore persistent scale so that we don't get tiny size on next startup
        setPaused(false);
    }
 
Example 12
Project: SER316-Munich   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 13
Project: OpenJSharp   File: FileChooserDemo.java   Source Code and License Vote up 4 votes
@SuppressWarnings("LeakingThisInConstructor")
public FilePreviewer(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    fc.addPropertyChangeListener(this);
}
 
Example 14
Project: SER316-Ingolstadt   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 15
Project: SER316-Aachen   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 16
Project: jdk8u-jdk   File: FileChooserDemo.java   Source Code and License Vote up 4 votes
@SuppressWarnings("LeakingThisInConstructor")
public FilePreviewer(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    fc.addPropertyChangeListener(this);
}
 
Example 17
Project: openjdk-jdk10   File: FileChooserDemo.java   Source Code and License Vote up 4 votes
@SuppressWarnings("LeakingThisInConstructor")
public FilePreviewer(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    fc.addPropertyChangeListener(this);
}
 
Example 18
Project: Reinickendorf_SER316   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 19
Project: Dahlem_SER316   File: ImagePreview.java   Source Code and License Vote up 4 votes
public ImagePreview(JFileChooser fc) {
    setPreferredSize(new Dimension(100, 50));
    setBorder(new TitledBorder(BorderFactory.createEtchedBorder(), 
    Local.getString("Preview"), TitledBorder.CENTER, TitledBorder.ABOVE_TOP));
    fc.addPropertyChangeListener(this);
}
 
Example 20
Project: jaer   File: AEPlayer.java   Source Code and License Vote up 3 votes
/**
 * adds a key-released listener on the JFileChooser FilePane inner
 * classes so that user can use Delete key to delete the file that is
 * presently being shown in the preview window
 *
 * @param chooser the chooser
 * @param preview the data file preview
 */
public FileDeleter(JFileChooser chooser, ChipDataFilePreview preview) {
    super();
    this.chooser = chooser;
    this.preview = preview;
    chooser.addPropertyChangeListener(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY, this);
    Component comp = addDeleteListener(chooser);
}