JFileChooser to get file path

Hallo,Is ther any method return the path of file choosen from the FileChooser component to my TextField of my frame?
[144 byte] By [asmainfa] at [2007-11-26 19:36:49]
# 1
JFileChooser api has getSelectedFile(), which returns a FileFile api has a number of methods that return 'paths'
Michael_Dunna at 2007-7-9 22:13:06 > top of Java-index,Desktop,Core GUI APIs...
# 2

hey,

Thank you for your help,

What about a jar file, if I choose a jar file ,how can I Know all its files names that it is contained without extracting it?

There is a entries () method in a JarFile class which return enumeration for the zip file entries. So I can make a loop to extract file names, but the problem is:

That the file returned by getSelectedFile() method is a File type, but if I choose the jar file type "example : Hello.jar" ,I would like to use the entries method at this file but in the program its type is File ,

how can i make it JarFile type?

Here it is a part of a code of my program:

/*global variable*/

Static private final String newline = "\n";

[b]JFileChooser[/b]fc;

/* a part of a program code*/

//the file chosen 揷ase: if it is a jar file type?/font>

//but its type is File not JarFile

[b]File[/b] file = fc.getSelectedFile();

try {

//I tries to convert the file to jar file but it is impossible

[b]JarFile[/b] jarFile =(JarFile) file;

} catch (IOException ex) {

ex.printStackTrace();

}

//entries method to extract the files name that the jar file contains

[b]Enumeration[/b] entre = jarFile.entries();

while(entre.hasMoreElements()){

[b]File[/b] f= (File) entre.nextElement();

classList.append("openning :"+ f.toString()+"."+newLine);

}

asmainfa at 2007-7-9 22:13:06 > top of Java-index,Desktop,Core GUI APIs...
# 3
Just create an instance of JarFile from your File:File file = fileChooser.getSelectedFile();JarFile jar = new JarFile(file);Geoff
glevnera at 2007-7-9 22:13:06 > top of Java-index,Desktop,Core GUI APIs...