From ec8efcaa76b682f8d1995c46b5caabb079dee3bb Mon Sep 17 00:00:00 2001 From: Sollace Date: Tue, 3 Jul 2018 19:04:26 +0200 Subject: [PATCH] Remember the last opened location between picking files --- .../hdskins/upload/awt/ThreadOpenFile.java | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java index df2005c3..56bb34ce 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java @@ -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); }