use of javax.swing.JFileChooser in project jadx by skylot.
the class MainWindow method openFile.
public void openFile() {
JFileChooser fileChooser = new JFileChooser();
fileChooser.setAcceptAllFileFilterUsed(true);
String[] exts = { "apk", "dex", "jar", "class", "zip", "aar" };
String description = "supported files: " + Arrays.toString(exts).replace('[', '(').replace(']', ')');
fileChooser.setFileFilter(new FileNameExtensionFilter(description, exts));
fileChooser.setToolTipText(NLS.str("file.open"));
String currentDirectory = settings.getLastOpenFilePath();
if (!currentDirectory.isEmpty()) {
fileChooser.setCurrentDirectory(new File(currentDirectory));
}
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.open"));
if (ret == JFileChooser.APPROVE_OPTION) {
settings.setLastOpenFilePath(fileChooser.getCurrentDirectory().getPath());
openFile(fileChooser.getSelectedFile());
}
}
use of javax.swing.JFileChooser in project jadx by skylot.
the class MainWindow method saveAll.
private void saveAll(boolean export) {
settings.setExportAsGradleProject(export);
if (export) {
settings.setSkipSources(false);
settings.setSkipResources(false);
}
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
fileChooser.setToolTipText(NLS.str("file.save_all_msg"));
String currentDirectory = settings.getLastSaveFilePath();
if (!currentDirectory.isEmpty()) {
fileChooser.setCurrentDirectory(new File(currentDirectory));
}
int ret = fileChooser.showDialog(mainPanel, NLS.str("file.select"));
if (ret == JFileChooser.APPROVE_OPTION) {
settings.setLastSaveFilePath(fileChooser.getCurrentDirectory().getPath());
ProgressMonitor progressMonitor = new ProgressMonitor(mainPanel, NLS.str("msg.saving_sources"), "", 0, 100);
progressMonitor.setMillisToPopup(0);
wrapper.saveAll(fileChooser.getSelectedFile(), progressMonitor);
}
}
use of javax.swing.JFileChooser in project languagetool by languagetool-org.
the class Tools method openFileDialog.
private static File openFileDialog(Frame frame, FileFilter fileFilter, File initialDir, int mode) {
JFileChooser jfc = new JFileChooser();
jfc.setFileSelectionMode(mode);
jfc.setCurrentDirectory(initialDir);
jfc.setFileFilter(fileFilter);
jfc.showOpenDialog(frame);
return jfc.getSelectedFile();
}
use of javax.swing.JFileChooser in project smile by haifengl.
the class PlotCanvas method save.
/**
* Shows a file chooser and exports the plot to the selected image file.
* @throws IOException if an error occurs during writing.
*/
public void save() throws IOException {
FileChooser.SimpleFileFilter filter = FileChooser.SimpleFileFilter.getWritableImageFIlter();
JFileChooser chooser = FileChooser.getInstance();
chooser.setFileFilter(filter);
chooser.setAcceptAllFileFilterUsed(false);
chooser.setSelectedFiles(new File[0]);
int returnVal = chooser.showOpenDialog(null);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile();
if (!filter.accept(file)) {
file = new File(file.getParentFile(), file.getName() + ".png");
}
save(file);
}
}
use of javax.swing.JFileChooser in project smile by haifengl.
the class PlotPanel method save.
/**
* Shows a file chooser and exports the plot to the selected image file.
* @throws IOException if an error occurs during writing.
*/
public void save() throws IOException {
JFileChooser fc = FileChooser.getInstance();
fc.setFileFilter(FileChooser.SimpleFileFilter.getWritableImageFIlter());
fc.setAcceptAllFileFilterUsed(false);
fc.setSelectedFiles(new File[0]);
int returnVal = fc.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = fc.getSelectedFile();
save(file);
}
}
Aggregations