Remember the last opened location between picking files

This commit is contained in:
Sollace 2018-07-03 19:04:26 +02:00
parent 6cc8e95991
commit ec8efcaa76

View file

@ -2,6 +2,8 @@ package com.voxelmodpack.hdskins.upload.awt;
import net.minecraft.client.Minecraft;
import java.io.File;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.filechooser.FileFilter;
@ -24,6 +26,8 @@ public abstract class ThreadOpenFile extends Thread {
private JFrame parent = null;
private static String lastChosenFile = null;
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
throws IllegalStateException {
if (minecraft.isFullScreen()) {
@ -43,10 +47,16 @@ public abstract class ThreadOpenFile extends Thread {
public void run() {
fileDialog = new JFileChooser();
fileDialog.setDialogTitle(this.dialogTitle);
if (lastChosenFile != null) {
fileDialog.setSelectedFile(new File(lastChosenFile));
}
fileDialog.setFileFilter(this.getFileFilter());
int dialogResult = fileDialog.showOpenDialog(parent);
lastChosenFile = fileDialog.getSelectedFile().getAbsolutePath();
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
}