Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Reply
 
Thread Tools Search this Thread Display Modes
Old Feb 16, 2006, 03:39 PM   #1
jtalerico
macrumors 6502
 
Join Date: Nov 2005
Yet anther fun Java question

So with JFileChooser I am trying to display the dir's and files on a remote server. Through FTP. But everytime it comes up, it will only show the client system filesystem.. Here is the code...

Code:
      JFrame frame = new JFrame("File Chooser");
                File curDir = new File(this.ftp.printWorkingDirectory());
                this.fc = new JFileChooser(curDir);
                int x = this.fc.showDialog(frame, "Open");
                if(x == this.fc.OPEN_DIALOG){
                    File dir = fc.getCurrentDirectory();
                    System.out.println(dir.toString());
It prints the local file system...

this.ftp is the FTPClient that is already connected to the server.
__________________
iPhone4
17" MacBook Pro i7 500GB SSD
MacPro 2011
jtalerico is offline   0 Reply With Quote
Old Feb 16, 2006, 04:15 PM   #2
cubist
macrumors 68020
 
Join Date: Jul 2002
Location: Muncie, Indiana
Send a message via AIM to cubist
this.ftp.printWorkingDirectory() will give you a string like "/usr/local". File, and then JFileChooser gets passed that string and, of course, it will think you are talking about a local directory. I don't see why you would think that JFileChooser will work the way you want, but, if it does, it will need to have more information than that.

Please check results of all calls, and add comments.
cubist is offline   0 Reply With Quote
Old Feb 16, 2006, 04:20 PM   #3
jtalerico
Thread Starter
macrumors 6502
 
Join Date: Nov 2005
Quote:
Originally Posted by cubist
this.ftp.printWorkingDirectory() will give you a string like "/usr/local". File, and then JFileChooser gets passed that string and, of course, it will think you are talking about a local directory. I don't see why you would think that JFileChooser will work the way you want, but, if it does, it will need to have more information than that.

Please check results of all calls, and add comments.

Right
this.ftp.printWorkingDirectory will return a string. File takes a string. Then JFileChooser takes in a File, which the file points to the directory on the server.

You do not think that JFileChooser will work? Why not?
__________________
iPhone4
17" MacBook Pro i7 500GB SSD
MacPro 2011
jtalerico is offline   0 Reply With Quote
Old Feb 16, 2006, 06:08 PM   #4
therevolution
macrumors 6502
 
Join Date: May 2003
Quote:
Originally Posted by jtalerico
Right
this.ftp.printWorkingDirectory will return a string. File takes a string. Then JFileChooser takes in a File, which the file points to the directory on the server.
You're passing a plain old String containing a pathname... how is it supposed to know that you want the path on the remote machine?

Have you tried doing a 'System.out.println("working dir: " + this.ftp.printWorkingDirectory());' to see what it looks like? That might help you understand what's going on.
therevolution is offline   0 Reply With Quote
Old Feb 16, 2006, 06:10 PM   #5
jtalerico
Thread Starter
macrumors 6502
 
Join Date: Nov 2005
From what i have read, Commons and JFileChooser do not work together.
__________________
iPhone4
17" MacBook Pro i7 500GB SSD
MacPro 2011
jtalerico is offline   0 Reply With Quote
Old Feb 16, 2006, 06:21 PM   #6
MarkCollette
macrumors 65816
 
MarkCollette's Avatar
 
Join Date: Mar 2003
Location: Calgary, Canada
JFileChooser shows File objects in a FileSystemView. The default FileSystemView is your local machine. If you want to make the JFileChooser show files on an FTP filesystem, then you have two choices:

1. Use native software that will map an FTP server into the local filesystem.
2. Write your own FileSystemView, which will expose the server's FTP filesystem, and pass this FileSystemView as a parameter to the JFileChooser.

I have personally written FileSystemViews to do the following:
- Show entries in a section of a hierarchial object oriented database, as if they were File objects. The also required extending File to support this.
- On older JVMs that didn't support showing the MS Windows Network Neighbourhood, I wrote JNI code to access the Win32 API for Network Neighbourhood, and wrapped it with a custom FileSystemView.
- An aggragate FileSystemView that could delegate the the "real" FileSystemView, or my database one, or my Network Neighbourhood one.
MarkCollette is offline   0 Reply With Quote

Reply
MacRumors Forums > Apple Systems and Services > Programming > Mac Programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Java question brentg33 OS X Mavericks (10.9) 2 Jan 25, 2014 09:42 AM
Java question brentg33 Mac Applications and Mac App Store 4 Aug 5, 2013 04:59 PM
Chrome on OS X -- Java plugin / Java 7 vs Java 6 Issue booyahbooyah Mac Applications and Mac App Store 4 May 31, 2013 09:13 AM
Java SE 7 13 question brentg33 Mac Applications and Mac App Store 1 Feb 2, 2013 12:11 PM
Java question brentg33 Mac Applications and Mac App Store 1 Aug 28, 2012 06:45 PM

Forum Jump

All times are GMT -5. The time now is 07:31 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC