Mega Code Archive

 
Categories / Java Tutorial / Swing
 

Creating a JFileChooser Dialog

import java.io.File; import javax.swing.JFileChooser; public class Main {   public static void main(String[] argv) {     String filename = File.separator + "tmp";     JFileChooser fc = new JFileChooser(new File(filename));     // Show open dialog     fc.showOpenDialog(null);     File selFile = fc.getSelectedFile();     // Show save dialog     fc.showSaveDialog(null);     selFile = fc.getSelectedFile();   } }