List of usage examples for javax.swing JFileChooser showOpenDialog
public int showOpenDialog(Component parent) throws HeadlessException
From source file:Main.java
public static void main(String[] args) throws Exception { String[] properties = { "os.name", "java.version", "java.vm.version", "java.vendor" }; for (String property : properties) { System.out.println(property + ": " + System.getProperty(property)); }/*from w w w . j ava 2s.c o m*/ JFileChooser jfc = new JFileChooser(); jfc.showOpenDialog(null); jfc.addChoosableFileFilter(new FileFilter() { @Override public boolean accept(File f) { return f.isDirectory() || f.getName().toLowerCase().endsWith(".obj"); } @Override public String getDescription() { return "Wavefront OBJ (*.obj)"; } @Override public String toString() { return getDescription(); } }); int result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); SwingUtilities.updateComponentTreeUI(jfc); jfc.showOpenDialog(null); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); for (UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { if ("Nimbus".equals(info.getName())) { UIManager.setLookAndFeel(info.getClassName()); SwingUtilities.updateComponentTreeUI(jfc); break; } } jfc.showOpenDialog(null); result = JOptionPane.showConfirmDialog(null, "Description was 'All Files'?"); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); chooser.setAccessory(new MyAccessory(chooser)); chooser.showOpenDialog(null); }
From source file:Main.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); fileChooser.showOpenDialog(null); }
From source file:JavaFileView.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser(); fileChooser.setFileView(new JavaFileView()); fileChooser.showOpenDialog(null); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser fileChooser = new JFileChooser(new File(".")); fileChooser.addChoosableFileFilter(new MyFilter()); fileChooser.showOpenDialog(null); System.out.println(fileChooser.getSelectedFile()); }
From source file:Main.java
public static void main(String[] argv) { JFileChooser chooser = new JFileChooser(); boolean hidingEnabled = chooser.isFileHidingEnabled(); chooser.setFileHidingEnabled(false); chooser.showOpenDialog(null); }
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);//from w w w. ja va 2s .co m chooser.showOpenDialog(null); File curFile = chooser.getSelectedFile(); }
From source file:MainClass.java
public static void main(String[] a) { JFileChooser fileChooser = new JFileChooser("."); fileChooser.setAccessory(new LabelAccessory(fileChooser)); int status = fileChooser.showOpenDialog(null); if (status == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); System.out.println(selectedFile.getParent()); System.out.println(selectedFile.getName()); } else if (status == JFileChooser.CANCEL_OPTION) { System.out.println("JFileChooser.CANCEL_OPTION"); }/* www.jav a 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("filename.txt").getCanonicalPath()); chooser.setSelectedFiles(new File[] { f }); chooser.showOpenDialog(null); File curFile = chooser.getSelectedFile(); }
From source file:com.acmutv.ontoqa.GrammalexMain.java
/** * The app main method, executed when the program is launched. * @param args The command line arguments. * @throws IllegalAccessException //from w w w . j av a 2 s. c om * @throws InstantiationException */ public static void main(String[] args) throws InstantiationException, IllegalAccessException { //CliService.handleArguments(args); RuntimeManager.registerShutdownHooks(new ShutdownHook()); try { Path path = FileSystems.getDefault().getPath("data/lexicon").toAbsolutePath(); String currentDirectory = path.toString(); final JFileChooser fc = new JFileChooser(currentDirectory); int returnVal = fc.showOpenDialog(null); fc.setFileSelectionMode(JFileChooser.FILES_ONLY); if (returnVal == JFileChooser.OPEN_DIALOG) { File file = fc.getSelectedFile(); System.out.println("File Select: " + file.getName() + "\n\n"); List<LexicalEntry> lEntries = LexiconUsage.getLexicalEntries(file.getAbsolutePath(), "", LexiconFormat.RDFXML); Grammar grammar = SerializeSltag.getAllElementarySltag(lEntries); SerializeSltag.writeGrammarOnFile(grammar, fileJson); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.exit(0); }