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 s[]) { JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File(".")); chooser.setDialogTitle("choosertitle"); chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); chooser.setAcceptAllFileFilterUsed(false); if (chooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { System.out.println("getCurrentDirectory(): " + chooser.getCurrentDirectory()); System.out.println("getSelectedFile() : " + chooser.getSelectedFile()); } else {//from w w w . j a v a2 s . c o m System.out.println("No Selection "); } }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); int result = chooser.showOpenDialog(null); switch (result) { case JFileChooser.APPROVE_OPTION: System.out.println("Approve (Open or Save) was clicked"); break;//from w w w . j a va 2 s . co m case JFileChooser.CANCEL_OPTION: System.out.println("Cancel or the close-dialog icon was clicked"); break; case JFileChooser.ERROR_OPTION: System.out.println("Error"); break; } }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); File file = new File("filename.txt"); String fileTypeName = chooser.getTypeDescription(file); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); File file = new File("c:\\Program Files"); file = new File("c:\\IO.SYS"); boolean isHidden = chooser.getFileSystemView().isHiddenFile(file); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); boolean enabled = chooser.isTraversable(new File("abc")); chooser.showOpenDialog(null);/* w w w . j a va 2s. c o m*/ }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); chooser.setMultiSelectionEnabled(true); chooser.showOpenDialog(null);//from w w w.ja va 2s . c o m File[] files = chooser.getSelectedFiles(); }
From source file:JFileChooserHidingFiles.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileHidingEnabled(false); fileChooser.showOpenDialog(null);/*from w ww . jav a 2s . c o m*/ }
From source file:Main.java
public static void main(String s[]) { JFileChooser chooser = new JFileChooser(); int rc = chooser.showOpenDialog(null); while (rc == JFileChooser.APPROVE_OPTION && !chooser.getSelectedFile().getName().endsWith(".java")) { JOptionPane.showMessageDialog(null, "The file " + chooser.getSelectedFile() + " is not java source file.", "Open Error", JOptionPane.ERROR_MESSAGE); rc = chooser.showOpenDialog(null); }/*from w w w . j ava2 s . com*/ }
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.setSelectedFile(f);/*ww w .jav a2 s. c o m*/ chooser.showOpenDialog(null); File curFile = chooser.getSelectedFile(); }
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 a v a 2s . com*/ chooser.setCurrentDirectory(null); chooser.showOpenDialog(null); File curDir = chooser.getCurrentDirectory(); }