Results 1 to 6 of 6

Thread: Network chooser from a JFileChooser

  1. #1
    Join Date
    Nov 2008
    Posts
    47

    Network chooser from a JFileChooser

    Hello everyone.
    I wanted to know whether it was possible to limit a JFileChooser access to a network. I wish that the user can not access the directory machines on the network in which it is located. But I do not want him to access files from the local machine. I Have look everywhere on the Internet and I did not find anything on the Internet Can Anybody Pls help ME Thanks in Advance

  2. #2
    Join Date
    May 2008
    Posts
    3,516

    Re: Network chooser from a JFileChooser

    According to this tutorial java I Have Read about Do this

    you can do:

    Code:
    JFileChooser fc = new JFileChooser (); 
    ... 
    fc.setFileFilter (new NetworkOnlyFileFilter ());

    NetworkOnlyFileFilter where class is a class that you have created that inherits from FileFilter, simply override the accept () and getDescription (), although I'm not on that you need getDescription () here.

    Good luck,

  3. #3
    Join Date
    Nov 2008
    Posts
    47

    Re: Network chooser from a JFileChooser

    I see very well what you mean and I want to believe that it may work. But I believe it should also be a path to FileChooser root loading the page and root this way has no physical existence (Network Neighborhood) but is a virtual directory of windows. It is quite at that level that I have a serious problem

  4. #4
    Join Date
    Feb 2008
    Posts
    2,635

    Re: Network chooser from a JFileChooser

    Quote Originally Posted by Spyrus View Post
    According to this tutorial java I Have Read about Do this

    you can do:

    Code:
    JFileChooser fc = new JFileChooser (); 
    ... 
    fc.setFileFilter (new NetworkOnlyFileFilter ());

    NetworkOnlyFileFilter where class is a class that you have created that inherits from FileFilter, simply override the accept () and getDescription (), although I'm not on that you need getDescription () here.

    Good luck,
    The argument to the showOpenDialog method specifies the parent component for the dialog. The parent component affects the position of the dialog and the frame that the dialog depends on. For example, the Java look and feel places the dialog directly over the parent component. If the parent component is in a frame, then the dialog is dependent on that frame. This dialog disappears when the frame is minimized and reappears when the frame is maximized.

    By default, a file chooser that has not been shown before displays all files in the user's home directory. You can specify the file chooser's initial directory by using one of JFileChooser's other constructors, or you can set the directory with the setCurrentDirectory method.

  5. #5
    Join Date
    Nov 2008
    Posts
    47

    Re: Network chooser from a JFileChooser

    It's good I found something. So, in fact, the goal of the game was to find the path virtual "Neighborhood Network" run by windows to add as fileSystemView the root directory of JFileChooser. For this, I use the java class ShellFolder.
    This is the piece of code:

    Code:
    / / Get all the special folders in Windows 
    File [] files = (File []) ShellFolder.get ( "fileChooserComboBoxFolders"); 
    File root = null; 
    
    for (int i = 0; i <files.length i + +) ( 
    / / = NETWORK_NEIGHBOURHOOD ":: (208D2C60-3AEA-1069-A2D7-08002B30309D)": the value of the directory in the registry 
    if (files [i]. getName (). equals (NETWORK_NEIGHBOURHOOD)) 
    ( 
    root = files [i]; 
    break; 
    ) 
    )
    And then this just creates a JFileChooser with this file as root and you have a FileChooser not allowing you to access the network and the like network neighborhood.

  6. #6
    Join Date
    Jan 2006
    Posts
    3,792

    Re: Network chooser from a JFileChooser

    Hello,

    but I have a question .... With your method outlined above are recovered in the end virtual "network neighborhood" and is set to root in the FileChooser.

    For the setter I have to root:

    Code:
    JFileChooser vFileChooser = new JFileChooser (root);

    to use your example, or with that, the record on which we arrive is network but nothing prevents the user back to the office via the combobox or the "home".

    But as I want to know the outcome of the story, I would like to know how you did

    Best regards,

Similar Threads

  1. Replies: 1
    Last Post: 24-04-2011, 11:54 PM
  2. Replies: 3
    Last Post: 23-12-2010, 07:10 PM
  3. Java JFileChooser
    By D_chapple in forum Software Development
    Replies: 5
    Last Post: 08-02-2010, 10:53 PM
  4. Anchoring a JFileChooser in a JFrame
    By technika in forum Software Development
    Replies: 5
    Last Post: 27-01-2010, 11:27 AM
  5. Contact Chooser feature in Gmail
    By Akiraa in forum Technology & Internet
    Replies: 3
    Last Post: 27-08-2009, 05:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,751,872,248.44557 seconds with 16 queries