mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 12:58:01 +01:00
Remember the last opened location between picking files
This commit is contained in:
parent
6cc8e95991
commit
ec8efcaa76
1 changed files with 10 additions and 0 deletions
|
@ -2,6 +2,8 @@ package com.voxelmodpack.hdskins.upload.awt;
|
||||||
|
|
||||||
import net.minecraft.client.Minecraft;
|
import net.minecraft.client.Minecraft;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
import javax.swing.JFileChooser;
|
import javax.swing.JFileChooser;
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
import javax.swing.filechooser.FileFilter;
|
import javax.swing.filechooser.FileFilter;
|
||||||
|
@ -24,6 +26,8 @@ public abstract class ThreadOpenFile extends Thread {
|
||||||
|
|
||||||
private JFrame parent = null;
|
private JFrame parent = null;
|
||||||
|
|
||||||
|
private static String lastChosenFile = null;
|
||||||
|
|
||||||
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
|
protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback)
|
||||||
throws IllegalStateException {
|
throws IllegalStateException {
|
||||||
if (minecraft.isFullScreen()) {
|
if (minecraft.isFullScreen()) {
|
||||||
|
@ -43,10 +47,16 @@ public abstract class ThreadOpenFile extends Thread {
|
||||||
public void run() {
|
public void run() {
|
||||||
fileDialog = new JFileChooser();
|
fileDialog = new JFileChooser();
|
||||||
fileDialog.setDialogTitle(this.dialogTitle);
|
fileDialog.setDialogTitle(this.dialogTitle);
|
||||||
|
|
||||||
|
if (lastChosenFile != null) {
|
||||||
|
fileDialog.setSelectedFile(new File(lastChosenFile));
|
||||||
|
}
|
||||||
fileDialog.setFileFilter(this.getFileFilter());
|
fileDialog.setFileFilter(this.getFileFilter());
|
||||||
|
|
||||||
int dialogResult = fileDialog.showOpenDialog(parent);
|
int dialogResult = fileDialog.showOpenDialog(parent);
|
||||||
|
|
||||||
|
lastChosenFile = fileDialog.getSelectedFile().getAbsolutePath();
|
||||||
|
|
||||||
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue