Disabling JFileChooser's rename and create new folder options

Thanx in advance.
Can anybody guide me as to how to disable the following in JFileChooser :
1. tool bar buttons where the user can create a new folder.
2. Renaming a file
regards,
Vikas

Ok, ok, here's the code. Again, don't use if you don't absolutely have to.
Use at your own risk. This is just an example. No guarantees given. Etc, etc.
import java.awt.*;
import java.awt.event.*;
import java.beans.*;
import javax.swing.*;
import javax.swing.table.*;
import javax.swing.plaf.basic.*;
public class ReadOnlyFileChooser extends JFileChooser {
    BasicFileChooserUI ui;
    public ReadOnlyFileChooser(String path) {
     super(path);
     if (System.getProperty("java.version").startsWith("1.4") &&
         getUI() instanceof BasicFileChooserUI) {
         ui = (BasicFileChooserUI)getUI();
         // Disable "New Folder" button
         ui.getNewFolderAction().setEnabled(false);
         addPropertyChangeListener(new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent ev) {
              if (ev.getPropertyName() == JFileChooser.DIRECTORY_CHANGED_PROPERTY) {
               SwingUtilities.invokeLater(new Runnable() {
                   public void run() {
                    ui.getNewFolderAction().setEnabled(false);
         String className = ui.getClass().getName();
         if (className.equals("javax.swing.plaf.metal.MetalFileChooserUI") ||
          className.equals("com.sun.java.swing.plaf.windows.WindowsFileChooserUI")) {
          // Disable editing (file renaming) in JList
          JList list = (JList)findByClass(this, JList.class);
          MouseListener[] listeners = list.getMouseListeners();
          for (int i = 0; i < listeners.length; i++) {
              className = listeners.getClass().getName();
          if (className.endsWith("FileChooserUI$SingleClickListener")) {
               list.removeMouseListener(listeners[i]);
               break;
          // Disable editing (file renaming) in JTable
          JToggleButton detailsViewButton = findDetailsViewButton(this);
          detailsViewButton.addActionListener(new ActionListener() {
          boolean done = false;
          public void actionPerformed(ActionEvent ev) {
               if (!done && ((JToggleButton)ev.getSource()).isSelected()) {
               SwingUtilities.invokeLater(new Runnable() {
                    public void run() {
                    JTable table =
                         (JTable)findByClass(ReadOnlyFileChooser.this,
                                   JTable.class);
                    if (table != null) {
                         TableColumn column =
                         table.getColumnModel().getColumn(0);
                         column.setCellEditor(null);
               done = true;
private static Component findByClass(Component comp, Class cls) {
     if (cls.isInstance(comp)) {
     return comp;
     } else if (comp instanceof Container) {
     Component[] comps = ((Container)comp).getComponents();
     for (int i = 0; i < comps.length; i++) {
          Component c = findByClass(comps[i], cls);
          if (c != null) {
          return c;
     return null;
private static JToggleButton findDetailsViewButton(Component comp) {
     Icon detailsViewIcon = UIManager.getIcon("FileChooser.detailsViewIcon");
     if (comp instanceof JToggleButton &&
     ((JToggleButton)comp).getIcon() == detailsViewIcon) {
     return (JToggleButton)comp;
     } else if (comp instanceof Container) {
     Component[] comps = ((Container)comp).getComponents();
     for (int i = 0; i < comps.length; i++) {
          JToggleButton button = findDetailsViewButton(comps[i]);
          if (button != null) {
          return button;
     return null;
public static void main(String[] args) {
     new ReadOnlyFileChooser(null).showOpenDialog(null);
     System.exit(0);

Similar Messages

  • Create New folder options is not coming in OBIEE 11G.

    Hello Everyone,
    I am testing Authorization part of the dashboard rite-now and issue is like I am not able to Create any New Folder within My Folder for Catalog.
    I gave my self Read, Traverse Access to dashboard and Reports that are stored in Shared Folder, now I want to use Shared folder's Reports and want to create My Dashboard. but even I am not able to Create My Dashboard too because I can't save any reports in My Folder.
    I checked with Manage Privileges      options too, where I gave access to any Authenticated Users to create Personal Storage (My Folders and My Dashboard) , Create Folders , Save Customizations ..
    if there any other change that i need to do???
    Thanking you..

    Hi Veer,
    Yes, I just tested this thing out in 11.1.1.5. Please find more details below.
    1. I create a sample 'BIConsumer' user.
    2. Logged into the BI Server.
    3. Navigated to Catalog and clicked on New
    4. I could get only two options 'Report Job' and 'Action Intelligence'.
    To provide proper privileges,
    1. Logged into BI Server as BIAdministrator.
    2. Navigated to Administration -> Manage Privileges -> Catalog/
    3. Given explicit permissions to 'BIConsumer' to create folders and 'My folders and Dashboard'.
    To verify,
    1. Logged back to BI Server as 'BIConsumer' user.
    2. Now, in the catalog could see 'New Folder' option under 'My folders'
    For further analysis, can you please check which roles this particular user is having? You can click on username at the top right corner -> My Account->Roles and Catalog Groups.
    Thank you,
    Dhar

  • ITunes update removes quicklaunch icons and creates new folder each time

    Everytime I install an iTunes update, it removes my quicklaunch icon and creates a new start menu folder.  I keep the iTunes start menu folder in a 'Media' subfolder (to keep things organized), but each time I update iTunes on each of my computers it creates a new iTunes folder in the main start menu. Any way to make it stop doing this? Since I work on multiple machines, it can be really irritating to have to redo icons and move folders each time.
    Working on PCs (Dell work laptops) running Windows 7.
    Thanks!

    Unfortunately it won't go into disk mode. Even tried the "put your ipod on a flat surface" trick. I'm wondering if the battery hasn't stopped holding a charge. But it seems the symptoms would be more like a constant battery icon. Instead I'm getting the sad face everytime I try to put it in disk mode or reset. Ideas? Throw ipod against wall? Blow on it like old-school Nintendo cartridges?
    Oh, and yes, it is Windows formatted.
    Any and all help would be appreciated.

  • Trackpad mouse moving on its own and creating new folder on desktop

    This stared a few weeksd ago, I've lost control of my macbook pro as my mouse has a mind of its own.
    The laptop barely(or even not at all) responds to my control.  It's like there was somebody else controlling my mouse, my keyboard works fine however.  The guy hacking me looked at my mailbox, dropped a few things from the dock, made a new folder on the desktop and opened my photos.  I've tried everything including  turning off wi-if, my reuter and under "system preferences" unclicked "sharing" of anything. I also took it to the genius bar to have my laptop wiped and updated to OS X Mountain Lion.
    Last week, my mouse again started to move on its own and created a new folder on my destop.
    I don't know if anyone has the same experience...and if so, please let me know what is going on and is there a solution?
    Thank you

    Woah, I just got this really sketchy email a few hours later. It's a bounce back from an invalid address, but it includes the previous few messages too... these guys are definitely speaking in some sort of code.
    I pasted it on this google doc for your inspection, pretty crazy. Do you think it could be related to this cursor moving incident? Did I get remotely hacked or something?
    https://docs.google.com/document/d/1NlP_g-skisehtH-kEMKPvYjDL5hrhyGPBcCpS_L4_AI/ edit?hl=en_US

  • Create New Folder Option

    Sorry for a simple question. Can't seem to find the answer in "search."
    When I create a new folder, it always defaults to the root directory and I must drag and drop it to the directory I want it in, essentially creating a sub directory. I imagine I'm missing something here and should be able to create a new folder in any directory/sub directory I need, correct?
    Thanks in advance!

    Open a finder window, select: view > customize toolbar, a sub window with a
    set of buttons appears. Point to each button to see an explanation of what it does. You can do any of the following:
    Add a button: Drag it to the toolbar.
    #add the new folder button to the toolbar, now you may create a new folder at will in whatever
    folder you are viewing at the time.#
    Add space between buttons: Drag Separator, Space, or Flexible Space to the toolbar.
    Return to default toolbar: Drag the default set to the toolbar.
    After making modifications click "Done"
    Kj

  • When I want to organise my bookmarks most of the options are greyed out and cannot be used including create new folder! Help

    '''''''''bold text'''''''''
    When i want to organise my bookmarks most of the options on the organise bookmarks menu are greyed out and cannot be used - including create new folder etc. Help please.

    Make sure you are not in the Private Browsing Mode:
    File > Private Browsing is UNCHECKED.

  • Can't create new folder on an external hard drive, and how to transfer files?

    Hello everyone,
    the non-English speaking videographer I translate for is having problems operating his Premiere CS5 for Mac from an external hard drive. He cannot create new folder on the external hard drive (the "New Folder" button is grayed-out when tries to export media onto the external hard drive) and when he simply tries to create new folder, the "new folder" option isn't available.
    He suspects it's because the hard drive was formatted for PC.
    Questions:
    - should PC-formatting cause that problem?
    - what's the proper way to transfer media files from PC-formatted external hard drive to the internal hard drive on Mac?
    Would appreciate your advice.
    Dimitri Vorontzov

    He is right on the money
    Now, for the sad or FAT part. You need to format the drive as FAT32 to make it work both on PC and MAC but, and that is a big BUT, the max file size of any given file will be 4GB. I haven't treid other formats yet, like the journaled MAC OS extended, but I don't think that would work. We transfer our files through or own gigabit network so I never had to try it, other than FAT32 formatted SDHC cards.

  • TS2446 My child wants her own Apple ID for her new phone and mac book. Not sure of steps to disable and creat new account while transferring photos etc. thoughts ?

    My child wants her own Apple ID for her phone and mac book. Not sure of steps to disable and create new account while transferring photos etc. thoughts ?

    Welcome to the Apple Community.
    Unfortunately, if Apple simply allowed people to log into different accounts and download content, everyone would be using everyone could share everyone else's content and bypass the need to purchase anything. To protect against this, they limit you to logging into a new account to once every 90 days.
    If two or more of you, have different accounts and use only one computer, you should each have your own user account on the computer, to avoid the need to log in and out of iTunes.

  • UCM - WEBDAV - How to Disable the New Folder option in the action popup

    I am trying to implement WebDav functionality. I don't want the users to create folders in the folder mapped to a security group. As long as the user has privilege to contribute to the security group he/she can checkin documents but they should not be able to create folder under it. I did not find documentation as to how to disable the new folder option in the context action menu that pops up on mouse right click. Is there any way we can do that?
    Thanx.
    Edited by: user10991492 on Nov 1, 2010 11:24 AM

    This is the boilerplate text often used in connection to networks in general. It is impossible to troubleshoot someone else's network remotely, and that's why it's not supported by Adobe:
    If you are opening files over a network or saving them to a network server, please cease and desist immediately in the event you are currently experiencing problems with one or more files.
    Working across a network in general is not supported by Adobe.
    See: 
    http://kb2.adobe.com/cps/406/kb406793.html
      Copy the CLOSED file from your server to your local hard disk, work on it, save it again to your local hard disk, close it, and copy the closed file back to the server.
        Of course, the fact that Adobe does not support working across a network does not necessarily mean it won't work.  It should.
        Adobe's position is that there are too many variables in a network environment for them to guarantee that everything will work correctly in every network, especially given the fact that if something does not work properly, it's probably the network's fault, and Adobe has no way of troubleshooting your network.
      If you can't work locally, you are on your own, and if something happens, you're on your own. If you must work from a server, make sure your network administrator is a competent professional.

  • LR 4 & 4.1 can't create new folder manually during photo import

    Windows 64, i7, 12GB RAM
    I don't seem able to create a new folder manually on photo import.  This still works fine on the same PC with LR3.6.  Anyone else seeing this?  Thanks.

    I've sometimes found the 'Make New Folder' option to be a bit hit and miss on Win7....so I generally avoid it. In your case, wouldn't it be easier to have Lightroom create the folder for you by setting up your Destination panel as follows:
    Obviously the selected target parent folder in your case would be "Photos Working Folders", use "Organize: Into One Folder", tick the Into Subfolder box and enter the name of the sub-folder you want, e.g. raw0015. As you can see, if the sub-folder doesn't yet exist, Lightroom then shows you that it will be creating it for you.

  • Not able to create new folder in list/library sharepoint 2013 foundation

    I am not able to create new folder in library and also not able to edit existing list item
    Below is the error:
    Getting Error Message for Exception 
              System.Web.HttpUnhandledException (0x80004005): Exception of type 
              'System.Web.HttpUnhandledException' was thrown. ---> 
              System.NullReferenceException: Object reference not set to an 
              instance of an object.     at 
              Microsoft.SharePoint.WebPartPages.ListFormWebPart.EnsureList()     
              at Microsoft.SharePoint.WebPartPages.ListFormWebPart.EnsureListAndFor
              m()     at 
              Microsoft.SharePoint.WebPartPages.ListFormWebPart.UseLegacyForm()    
               at Microsoft.SharePoint.WebPartPages.ListFormWebPart.CreateChildCont
              rols()     at System.Web.UI.Control.EnsureChildControls()     at 
              Microsoft.SharePoint.WebPartPages.WebPart.get_WebPartMenu()     at Mi
              crosoft.SharePoint.WebPartPages.ListFormWebPart.CreateWebPartMenu()  
                 at Microsoft.SharePoint.WebPartPages.ListFormWebPart.OnLoad(Ev...
    Please help.It happens only on few sub sites

    Hi V_K04,
    You said that it happened only on few sub sites, whether this issue occurred on some subsites, and some subsite worked well.
    Please check whether there are some differences between the subsites that worked well and the problematic subsites. 
    Whether this issue occurred on all libraries and lists on problematic subsites.
    Whether there are some customizations in these problematic libraries and lists.
    Please create a new library and a new list, test again, compare the result.
    BestRegards,
    Wendy
    Wendy Li
    TechNet Community Support

  • Creating new folder in sharepoint

    Hi - I am using Office 2013 and using the "Save as" function in Word want to create a new folder on the SharePoint site. there does not seem to be any way to do this through the "save as" dialog process. The "new folder" option
    only seems to be available for saving on the local hard drive. It seems I need to go into file explorer, create a new folder and then go back into Word to save to it.
    Thanks - Tim

    Hi,
    A quick hack for this if you use the same document library over and over is to map a network drive to the library, then when you save to the network drive (and thus the document library) you'll see the new folder option available and working.
    A second method, would be to click on the address bar in the save as dialog, remove the "http:" and change "/" to "\".  For instance:
    http://mysite/personal/iedaddy
    would become
    \\mysite\personal\iedaddy
    and then magically the Organize and New Folder menu bar appears, interestingly this method will also allow you to add new folders even to libaries with the "New Folder" option explicitly turned off.
    A similar problem can be found here:
    http://social.technet.microsoft.com/forums/sharepoint/en-US/e7a5d817-226f-4d13-b1be-1270bf065301/office-2013-save-as-new-folder-for-a-sharepoint-2013-site
    Regards,
    Melon Chen
    TechNet Community Support

  • Create new folder with selected items

    I have a bunch of movies that I would like to place into individual folders of the same name (Without the extension name). I wanted to try and create a keyboard command to do this with the selected files, but can't manage to figure out how!
    What I did was try to create a new service command in automator, then went to keyboard shortcuts in system preferences to assign a keyboard command to it.
    I want to make something that works like control-command-n (to create new folder from selected items), only I want the items to be in individual folders of the same name.
    eg.
    Files selected such as:
    The incredibles.avi
    Cinderella.mkv
    Dogma.mp4
    each moved into individual folders labeled as:
    The Incredibles
    Cinderella
    Dogma
    Also, is there a way to change the control-command-n shortcut so it can create a new folder from a single item? It only works when there is more than one file selected.
    Thanks so much for any help!

    I am going to guess that you start off with a single file - what are you doing to generate these files? My *Get Names of Finder Items* action can get a name to use in the *New Folder* action - items passed to the New Folder action will get copied to it, so a little more detail may help in creating the workflow.
    The *Dispense Items Incrementally* action can also be used to dole out the items one at a time - knowing what the workflow is doing would help with the use of this action as well.

  • Creating new folder ripple effect in other folders

    I was in the RoboHelp 7 Project Manager pod. The HTML Files (Topics) folder was highlighted. I right-clicked and selected New > Folder.
    I named the new folder Assets and pressed Enter to create the folder. All on its own, RH created an Assets folder under the Images, Multimedia, Style Sheets, and Baggage Files folders.
    Not only that, but every folder I created under the Assets folder was also duplicated under the  Images, Multimedia, Style Sheets, and Baggage Files folders. AND, if I try then to delete one of those folders, either a.) the Delete option is not available on the right-click menu or b.) When it is available and I select it, ALL instances of the folder are deleted.
    Why did RH create multiple Assets folders and why can't I create a single folder under only the HTML Files (Topics) folder?

    Hi there
    This is perfectly normal. You need to understand that the Project Manager is simply RoboHelp's way of organizing the different project assets. Think of it as perhaps "filters" that are only showing you files that are used. For example, when you look at the files and folders of the project in Windows Explorer, you will never see a folder named "Baggage Files" or "Style Sheets". And if you create a folder, even though you see it in Baggage Files, Images, Cascading Style Sheets and HTML Topics, it's only on your hard drive once.
    Hopefully this helps... Rick
    Begin learning RoboHelp HTML 7 within the day - $24.95!
    Click here for Adobe Certified Captivate and RoboHelp HTML Training
    Click here for the SorcerStone Blog
    Click here for RoboHelp and Captivate eBooks

  • Cannot create new folder?

    I have just moved to a new hosting and have connected to it
    and I can edit files. When I try to add a folder to the remove I'll
    get
    "An FTP error occured - cannot create new folder .
    Access denied. The file may not exist or there could be a
    permission problem".
    Any idea?

    Hi,
    Did you make any changes before the issue appears?
    Before going further, you may try the
    system restore to go back to a previous status and check the result.
    Tracy Cai
    TechNet Community Support

Maybe you are looking for

  • Calendars in iCal disappeared

    HI All of the individual calendars I had set up within iCal (they show in the left panel) have disappeared and when I open iCal all the days are blank....no events or appts. are there! If I click on the 'search results list' button a list of all my a

  • Getting an error while selecting from table having CLOB column.

    Hi All, I have below table created in My oracle database version Oracle Database 11g Enterprise Edition Release 11.2.0.1.0. CREATE TABLE my_clob -- Dummy table created (DataBody CLOB); Current Database Character set - WE8MSWIN1250. On the front end o

  • Excel import rounding up decimal values

    In my excel file I have a column that contains dollars and cents (e.g. 49.95). When I run the import the values in this column are rounded up to the next integer (e.g. 49.95 is rounded up to 50). Is this a bug or am I doing something wrong? Thanks, P

  • Making the jump IDVD to DVDSP - Apply chapters to DVD?

    Ok... I took the advice of many. Started using compressor to begin making DVDS with DDVSP. So here is where I'm at. I finally got my FCP white water rafting movie formatted and filed correctly with chapter markers using compressor. I imported the ass

  • How to INSTALL the SAP?

    Can anyone tell me how to INSTALL the SAP ?