List of utility methods to do JFileChooser
JFileChooser | getTextFileChooser() Gets a text file chooser. final JFileChooser chooser = new JFileChooser(); FileNameExtensionFilter filter = new FileNameExtensionFilter("Text files", "txt"); chooser.setFileFilter(filter); return chooser; |
JFileChooser | getXmlFileChooser() get Xml File Chooser JFileChooser xmlFileChooser = new JFileChooser(); FileFilter filter = new FileFilter() { public boolean accept(File file) { if (file.isDirectory()) return true; String name = file.getName().toLowerCase(); return name.endsWith(".xml"); public String getDescription() { return "XML"; }; xmlFileChooser.setFileFilter(filter); return xmlFileChooser; |
String | importFile(JFileChooser jFileChooser) import File StringBuilder stringBuilder; int result = jFileChooser.showOpenDialog(null); if (result == JFileChooser.APPROVE_OPTION) { final ArrayList<String> parfileTextLines = myReadDataFile(jFileChooser.getSelectedFile().toString()); stringBuilder = new StringBuilder(); for (String currLine : parfileTextLines) { stringBuilder.append(currLine); stringBuilder.append("\n"); ... |
JFileChooser | initFileChooser(JFileChooser fileChooser, FileFilter filter) init File Chooser if (fileChooser.getSelectedFile() != null) { fileChooser = new JFileChooser(fileChooser.getSelectedFile().getPath()); if (filter != null) { fileChooser.setFileFilter(filter); return fileChooser; |
boolean | isDriveTraversable(File drive) is Drive Traversable return fsv.isTraversable(drive);
|
String | loadFile() load File JFileChooser fileChooser = new JFileChooser(lastTouchedDirectory); fileChooser.setApproveButtonText("Load"); if (fileChooser.showOpenDialog(null) == JFileChooser.APPROVE_OPTION) { File selectedFile = fileChooser.getSelectedFile(); lastTouchedFileName = selectedFile.getName(); lastTouchedDirectory = selectedFile.getParent(); return loadFile(selectedFile); return null; |
java.io.File | loadFile(Component parent, String title) This method is used to choose a file path. JFileChooser chooser = new JFileChooser(); chooser.setCurrentDirectory(new java.io.File("./")); chooser.setDialogTitle(title); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setVisible(true); if (chooser.showOpenDialog(chooser) == JFileChooser.APPROVE_OPTION) { return chooser.getSelectedFile(); return null; |
T | loadFileAs(Class load File As try { return mapper.readValue(json, clazz); } catch (IOException e) { e.printStackTrace(); return null; |
JFileChooser | makeFileChooser() make File Chooser final JFileChooser temp = new JFileChooser(); final String dir = System.getProperty("user.dir"); final File fileDir = new File(dir); temp.setCurrentDirectory(fileDir); return temp; |
JFileChooser | openDataFileChooser(Component com) File chooser to read data files. JFileChooser fileChooser = new JFileChooser(); fileChooser.removeChoosableFileFilter(fileChooser.getAcceptAllFileFilter()); fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY); fileChooser.addChoosableFileFilter( new FileNameExtensionFilter("All *.jser,*.jxml,*.jpbu,*.jdat,*.root,*.aida,*.xml", "jser", "jxml", "jpbu", "jdat", "root", "aida", "xml")); fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("HFile (*.jser)", "jser")); fileChooser.addChoosableFileFilter(new FileNameExtensionFilter("HFileXML (*.jxml)", "jxml")); ... |