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

The following examples show how to use javax.swing.JFileChooser#setApproveButtonToolTipText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AddServerLocationVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser() {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);

    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.setApproveButtonToolTipText(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N

    chooser.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N

    // set the current directory
    chooser.setSelectedFile(new File(locationTextField.getText().trim()));

    return chooser;
}
 
Example 2
Source File: AddServerPropertiesVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser(){
    JFileChooser chooser = new JFileChooser();

    chooser.setDialogTitle("LBL_Chooser_Name"); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);

    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.addChoosableFileFilter(new dirFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonToolTipText("LBL_Chooser_Name"); //NOI18N

    chooser.getAccessibleContext().setAccessibleName("LBL_Chooser_Name"); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription("LBL_Chooser_Name"); //NOI18N

    return chooser;
}
 
Example 3
Source File: AddServerLocationVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser() {
    JFileChooser chooser = new JFileChooser();
    String t = NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName");
    chooser.setDialogTitle(t); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.addChoosableFileFilter(new DirFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonToolTipText(t); //NOI18N
    chooser.getAccessibleContext().setAccessibleName(t); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(t); //NOI18N

    // set the current directory
    File currentLocation = new File(hk2HomeTextField.getText());
    File currentLocationParent = currentLocation.getParentFile();
    if(currentLocationParent != null && currentLocationParent.exists()) {
        chooser.setCurrentDirectory(currentLocationParent);
    }
    if (currentLocation.exists() && currentLocation.isDirectory()) {
        chooser.setSelectedFile(currentLocation);
    } 
    
    return chooser;
}
 
Example 4
Source File: AddServerLocationVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser() {
    JFileChooser chooser = new JFileChooser();
    String t = NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName");
    chooser.setDialogTitle(t); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.addChoosableFileFilter(new DirFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonToolTipText(t); //NOI18N
    chooser.getAccessibleContext().setAccessibleName(t); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(t); //NOI18N

    // set the current directory
    File currentLocation = new File(hk2HomeTextField.getText());
    File currentLocationParent = currentLocation.getParentFile();
    if(currentLocationParent != null && currentLocationParent.exists()) {
        chooser.setCurrentDirectory(currentLocationParent);
    }
    if (currentLocation.exists() && currentLocation.isDirectory()) {
        chooser.setSelectedFile(currentLocation);
    } 
    
    return chooser;
}
 
Example 5
Source File: AddServerLocationVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser(){
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);

    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.setApproveButtonToolTipText(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N

    chooser.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ChooserName")); //NOI18N

    // set the current directory
    chooser.setSelectedFile(new File(locationTextField.getText().trim()));

    return chooser;
}
 
Example 6
Source File: AddServerPropertiesVisualPanel.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private JFileChooser getJFileChooser(){
    JFileChooser chooser = new JFileChooser();
    
    chooser.setDialogTitle("LBL_Chooser_Name"); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
    
    chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.addChoosableFileFilter(new dirFilter());
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonToolTipText("LBL_Chooser_Name"); //NOI18N
    
    chooser.getAccessibleContext().setAccessibleName("LBL_Chooser_Name"); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription("LBL_Chooser_Name"); //NOI18N
    
    return chooser;
}
 
Example 7
Source File: WildflyTabVisualPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
void decorateChooser(JFileChooser chooser,String fname,String title) {
    chooser.setDialogTitle(title);                                           //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);

    chooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    chooser.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.isDirectory() || (file.isFile() && file.getName().endsWith(".xml"));
        }

        @Override
        public String getDescription() {
            return "";
        }
    });
    chooser.setApproveButtonMnemonic(NbBundle.getMessage(WildflyTabVisualPanel.class,
            "Choose_Button_Mnemonic").charAt(0));                           //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.setAcceptAllFileFilterUsed(false);
    chooser.setApproveButtonToolTipText(NbBundle.getMessage(WildflyTabVisualPanel.class,
            "LBL_Chooser_Name"));                                           //NOI18N

    chooser.getAccessibleContext().
            setAccessibleName(NbBundle.getMessage(WildflyTabVisualPanel.class,
            "LBL_Chooser_Name"));                                           //NOI18N
    chooser.getAccessibleContext().
            setAccessibleDescription(NbBundle.getMessage(WildflyTabVisualPanel.class,
            "LBL_Chooser_Name"));                                           //NOI18N
    if (null != fname && fname.length() > 0) {
        File sel = new File(fname);
        if (sel.isDirectory())
            chooser.setCurrentDirectory(sel);
        else
            chooser.setSelectedFile(sel);
    }
}
 
Example 8
Source File: AddServerLocationVisualPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private JFileChooser getConfigJFileChooser() {
    JFileChooser chooser = new JFileChooser();
    chooser.setDialogTitle(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ConfigChooserName")); //NOI18N
    chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);

    chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
    chooser.setFileFilter(new FileFilter() {

        @Override
        public boolean accept(File file) {
            return file.isDirectory() || (file.isFile() && file.getName().endsWith(".xml"));
        }

        @Override
        public String getDescription() {
            return "";
        }
    });
    chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic".charAt(0)); //NOI18N
    chooser.setMultiSelectionEnabled(false);
    chooser.setApproveButtonToolTipText(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ConfigChooserName")); //NOI18N

    chooser.getAccessibleContext().setAccessibleName(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ConfigChooserName")); //NOI18N
    chooser.getAccessibleContext().setAccessibleDescription(NbBundle.getMessage(AddServerLocationVisualPanel.class, "LBL_ConfigChooserName")); //NOI18N

    // set the current directory
    chooser.setSelectedFile(new File(configurationTextField.getText().trim()));

    return chooser;
}
 
Example 9
Source File: FileChooser.java    From trufflesqueak with MIT License 5 votes vote down vote up
public static String run() {
    final JFileChooser squeakImageChooser = new JFileChooser();
    squeakImageChooser.setFileFilter(new SqueakImageFilter());
    squeakImageChooser.setApproveButtonToolTipText("Open selected image with TruffleSqueak");
    final long result = squeakImageChooser.showOpenDialog(null);
    if (result == JFileChooser.APPROVE_OPTION) {
        return squeakImageChooser.getSelectedFile().getAbsolutePath();
    }
    return null;
}
 
Example 10
Source File: ProjectChooserAccessory.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** 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 11
Source File: PatchAction.java    From netbeans with Apache License 2.0 4 votes vote down vote up
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;
   }