Skip to content

Instantly share code, notes, and snippets.

@maheshmc2
Created March 4, 2011 14:25
Show Gist options
  • Save maheshmc2/854677 to your computer and use it in GitHub Desktop.
Save maheshmc2/854677 to your computer and use it in GitHub Desktop.
Sample JFileChooser
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JPanel;
public class TestFileChooser extends JPanel {
public static void main(String... args){
TestFileChooser tf = new TestFileChooser();
tf.showMe();
// jf.showOpenDialog(TestFileChooser.this);
}
public void showMe(){
JFileChooser jf = new JFileChooser();
jf.showOpenDialog(TestFileChooser.this);
File f = jf.getSelectedFile();
System.out.println("File Choosen is: "+f.getName());
System.out.println("File Choosen is: "+f.getAbsolutePath());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment