List of usage examples for javax.swing JFileChooser JFileChooser
public JFileChooser()
JFileChooser
pointing to the user's default directory. From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File(".").getCanonicalPath()); chooser.setCurrentDirectory(f);/*from www .j ava 2s .com*/ chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); JComponent obj = chooser.getAccessory(); }
From source file:MainClass.java
public static void main(String[] args) { JFileChooser chooser = new JFileChooser(); FileSystemView view = chooser.getFileSystemView(); System.out.println("The home directory is " + view.getHomeDirectory()); }
From source file:Main.java
public static void main(String[] args) { // Display an open file chooser JFileChooser fileChooser = new JFileChooser(); int returnValue = fileChooser.showOpenDialog(null); if (returnValue == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); System.out.println("we selected: " + selectedFile); }/*from ww w . j a v a 2 s . c o m*/ }
From source file:Main.java
public static void main(String[] args) { JFileChooser chooser = new JFileChooser(); BasicFileChooserUI ui = (BasicFileChooserUI) chooser.getUI(); Action folder = ui.getNewFolderAction(); folder.setEnabled(false);//w w w .j a va 2 s . c o m chooser.showSaveDialog(null); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File(".").getCanonicalPath()); chooser.setCurrentDirectory(f);/*from ww w . j ava 2s .com*/ chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); FileFilter obj = chooser.getAcceptAllFileFilter(); }
From source file:MainClass.java
public static void main(String[] args) { JFileChooser chooser = new JFileChooser(); FileSystemView view = chooser.getFileSystemView(); System.out.println("The roots of this filesystem are: "); File[] roots = view.getRoots(); for (int i = 0; i < roots.length; i++) { System.out.println(" " + roots[i]); }//from ww w . ja va 2 s. co m }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File(".").getCanonicalPath()); chooser.setCurrentDirectory(f);/* w ww . ja v a 2 s . c o m*/ chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); AccessibleContext obj = chooser.getAccessibleContext(); }
From source file:Main.java
public static void main(String[] argv) throws Exception { JFileChooser chooser = new JFileChooser(); File f = new File(new File("filename.txt").getCanonicalPath()); chooser.setFileSystemView(FileSystemView.getFileSystemView()); chooser.showDialog(new JFrame(""), null); File curFile = chooser.getSelectedFile(); }
From source file:FileFilterDemo.java
public static void main(String[] args) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new File(".")); chooser.setFileFilter(new javax.swing.filechooser.FileFilter() { public boolean accept(File f) { return f.getName().toLowerCase().endsWith(".gif") || f.isDirectory(); }/*w w w . j ava 2s. co m*/ public String getDescription() { return "GIF Images"; } }); int r = chooser.showOpenDialog(new JFrame()); if (r == JFileChooser.APPROVE_OPTION) { String name = chooser.getSelectedFile().getName(); System.out.println(name); } }
From source file:Main.java
public static void main(String[] argv) { final JFileChooser chooser = new JFileChooser(); File curDir = chooser.getCurrentDirectory(); chooser.setDialogTitle("" + curDir.getAbsolutePath()); chooser.addPropertyChangeListener(new PropertyChangeListener() { public void propertyChange(PropertyChangeEvent evt) { if (JFileChooser.DIRECTORY_CHANGED_PROPERTY.equals(evt.getPropertyName())) { File curDir = chooser.getCurrentDirectory(); chooser.setDialogTitle("" + curDir.getAbsolutePath()); }/* www .ja v a 2 s . c o m*/ } }); }