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

The following are Jave code examples for showing how to use setApproveButtonToolTipText() 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: 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 2
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 3
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 4
Project: Squid   File: FileHelper.java   Source Code and License Vote up 5 votes
/**
 *
 * @param dialogTitle
 * @param location
 * @return
 */
public static File allPlatformGetFolder(
        String dialogTitle,
        File location) {

    File fractionFolder = null;

    JFileChooser fc = new JFileChooser();
    fc.setApproveButtonText("Select");
    fc.setApproveButtonToolTipText("Select the folder that will contain the Calamari Reports.");

    // this moves up one level so we can choose folder
    fc.setCurrentDirectory(location.getAbsoluteFile().getParentFile());
    fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    fc.setDialogTitle(dialogTitle);
    fc.setSelectedFile(location.getAbsoluteFile());
  
    // Show open dialog; this method does not return until the dialog is closed
    int result = fc.showOpenDialog(new JFrame());
    if (result == JFileChooser.APPROVE_OPTION) {
        fractionFolder = fc.getSelectedFile();
        if (!fractionFolder.exists()) {
            JOptionPane.showMessageDialog(null,
                    new String[]{"The folder does NOT exist."},
                    "ET Redux Warning",
                    JOptionPane.WARNING_MESSAGE);
        }
    }

    return fractionFolder;
}
 
Example 5
Project: racp   File: Window.java   Source Code and License Vote up 5 votes
public void save(){
	System.out.println("Save");
	
	if(currentFile == null){
		System.out.println("Save untitled.");
		
		JFileChooser fileChooser = new JFileChooser();
		fileChooser.setApproveButtonText("Save");
		fileChooser.setApproveButtonToolTipText("Save in this folder with the given name.");
		int returnVal =fileChooser.showOpenDialog(this);
		
		if( returnVal == JFileChooser.APPROVE_OPTION){
			File selectedFile = fileChooser.getSelectedFile();
			System.out.println("File approved: " + selectedFile);
			
			if(selectedFile.exists()){
				throw new IllegalArgumentException("Overwrite unimplemented.");
			}else{
				forceSave(selectedFile);
				System.out.println("Save successfull.");
			}
		}else{
			System.out.println("File not approved: " + returnVal);
		}
	}else{
		System.out.println("Saving opened file");
		forceSave(currentFile);
	}
}
 
Example 6
Project: racp   File: Window.java   Source Code and License Vote up 5 votes
public void load(){
	System.out.println("Save");
	
	JFileChooser fileChooser = new JFileChooser(currentFile);
	fileChooser.setApproveButtonText("Load");
	fileChooser.setApproveButtonToolTipText("Load the chosen file into the editor.");
	int returnVal =fileChooser.showOpenDialog(this);
	
	if( returnVal == JFileChooser.APPROVE_OPTION){
		File selectedFile = fileChooser.getSelectedFile();
		System.out.println("File approved: " + selectedFile);
		
		if(selectedFile.exists()){
			if(selectedFile.canRead()){
				try {
					loadFile(selectedFile);
				} catch (IOException e) {
					throw new IllegalArgumentException("Error loading file.", e);
				}
			}else{
				throw new IllegalArgumentException("Cannot read file");
			}
		}else{
			throw new IllegalArgumentException("File does not exist");
		}
	}else{
		System.out.println("File not approved: " + returnVal);
	}
	
}
 
Example 7
Project: incubator-netbeans   File: ProjectChooserAccessory.java   Source Code and License Vote up 4 votes
/** Factory method for project chooser
 */
public static JFileChooser createProjectChooser( boolean defaultAccessory ) {

    ProjectManager.getDefault().clearNonProjectCache(); // #41882

    OpenProjectListSettings opls = OpenProjectListSettings.getInstance();
    JFileChooser chooser = new ProjectFileChooser();
    chooser.setFileSelectionMode( JFileChooser.DIRECTORIES_ONLY );

    if ("GTK".equals(javax.swing.UIManager.getLookAndFeel().getID())) { // NOI18N
        // see BugTraq #5027268
        chooser.putClientProperty("GTKFileChooser.showDirectoryIcons", Boolean.TRUE); // NOI18N
        //chooser.putClientProperty("GTKFileChooser.showFileIcons", Boolean.TRUE); // NOI18N
    }

    chooser.setApproveButtonText( NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonText" ) ); // NOI18N
    chooser.setApproveButtonMnemonic( NbBundle.getMessage( ProjectChooserAccessory.class, "MNM_PrjChooser_ApproveButtonText" ).charAt (0) ); // NOI18N
    chooser.setApproveButtonToolTipText (NbBundle.getMessage( ProjectChooserAccessory.class, "BTN_PrjChooser_ApproveButtonTooltipText")); // NOI18N
    // chooser.setMultiSelectionEnabled( true );
    chooser.setDialogTitle( NbBundle.getMessage( ProjectChooserAccessory.class, "LBL_PrjChooser_Title" ) ); // NOI18N
    //#61789 on old macosx (jdk 1.4.1) these two method need to be called in this order.
    chooser.setAcceptAllFileFilterUsed( false );
    chooser.setFileFilter( ProjectDirFilter.INSTANCE );

    // A11Y
    chooser.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AN_ProjectChooserAccessory"));
    chooser.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ProjectChooserAccessory.class, "AD_ProjectChooserAccessory"));


    if ( defaultAccessory ) {
        chooser.setAccessory(new ProjectChooserAccessory(chooser, opls.isOpenSubprojects()));
    }

    File currDir = null;
    String dir = opls.getLastOpenProjectDir();
    if ( dir != null ) {
        File d = new File( dir );
        if ( d.exists() && d.isDirectory() ) {
            currDir = d;
        }
    }

    FileUtil.preventFileChooserSymlinkTraversal(chooser, currDir);
    new ProjectFileView(chooser);

    return chooser;

}
 
Example 8
Project: incubator-netbeans   File: PatchAction.java   Source Code and License Vote up 4 votes
private File getPatchFor(FileObject fo) {
       JFileChooser chooser = new JFileChooser();
       String patchDirPath = DiffModuleConfig.getDefault().getPreferences().get(PREF_RECENT_PATCH_PATH, System.getProperty("user.home"));
       File patchDir = new File(patchDirPath);
       while (!patchDir.isDirectory()) {
           patchDir = patchDir.getParentFile();
           if (patchDir == null) {
               patchDir = new File(System.getProperty("user.home"));
               break;
           }
       }
       FileUtil.preventFileChooserSymlinkTraversal(chooser, patchDir);
       chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
       String title = NbBundle.getMessage(PatchAction.class,
           (fo.isData()) ? "TITLE_SelectPatchForFile"
                         : "TITLE_SelectPatchForFolder", fo.getNameExt());
       chooser.setDialogTitle(title);

       // setup filters, default one filters patch files
       FileFilter patchFilter = new javax.swing.filechooser.FileFilter() {
           @Override
           public boolean accept(File f) {
               return f.getName().endsWith("diff") || f.getName().endsWith("patch") || f.isDirectory();  // NOI18N
           }
           @Override
           public String getDescription() {
               return NbBundle.getMessage(PatchAction.class, "CTL_PatchDialog_FileFilter");
           }
       };
       chooser.addChoosableFileFilter(patchFilter);
       chooser.setFileFilter(patchFilter);

       chooser.setApproveButtonText(NbBundle.getMessage(PatchAction.class, "BTN_Patch"));
       chooser.setApproveButtonMnemonic(NbBundle.getMessage(PatchAction.class, "BTN_Patch_mnc").charAt(0));
       chooser.setApproveButtonToolTipText(NbBundle.getMessage(PatchAction.class, "BTN_Patch_tooltip"));
       HelpCtx ctx = new HelpCtx(PatchAction.class.getName());
       DialogDescriptor descriptor = new DialogDescriptor( chooser, title, true, new Object[0], null, 0, ctx, null );
       final Dialog dialog = DialogDisplayer.getDefault().createDialog( descriptor );
       dialog.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(PatchAction.class, "ACSD_PatchDialog"));

       ChooserListener listener = new PatchAction.ChooserListener(dialog,chooser);
chooser.addActionListener(listener);
       dialog.setVisible(true);

       File selectedFile = listener.getFile();
       if (selectedFile != null) {
           DiffModuleConfig.getDefault().getPreferences().put(PREF_RECENT_PATCH_PATH, selectedFile.getParentFile().getAbsolutePath());
       }
       return selectedFile;
   }