From 9780379a9e3d95234dd2b41719139390ad4a21c1 Mon Sep 17 00:00:00 2001 From: Sollace Date: Wed, 8 Aug 2018 14:52:44 +0200 Subject: [PATCH] Check for empty-ish strings, not just null --- .../hdskins/upload/awt/ThreadOpenFile.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) 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 51502a90..df2edaab 100644 --- a/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java +++ b/src/hdskins/java/com/voxelmodpack/hdskins/upload/awt/ThreadOpenFile.java @@ -7,6 +7,8 @@ import java.io.File; import javax.swing.JFileChooser; import javax.swing.filechooser.FileFilter; +import org.apache.commons.lang3.StringUtils; + /** * Base class for "open file" dialog threads * @@ -21,12 +23,9 @@ public abstract class ThreadOpenFile extends Thread { */ protected final IOpenFileCallback parentScreen; - private JFileChooser fileDialog; - private static String lastChosenFile = null; - protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) - throws IllegalStateException { + protected ThreadOpenFile(Minecraft minecraft, String dialogTitle, IOpenFileCallback callback) throws IllegalStateException { if (minecraft.isFullScreen()) { throw new IllegalStateException("Cannot open an awt window whilst minecraft is in full screen mode!"); } @@ -37,13 +36,13 @@ public abstract class ThreadOpenFile extends Thread { @Override public void run() { - fileDialog = new JFileChooser(); - fileDialog.setDialogTitle(this.dialogTitle); + JFileChooser fileDialog = new JFileChooser(); + fileDialog.setDialogTitle(dialogTitle); - if (lastChosenFile != null) { + if (!StringUtils.isBlank(lastChosenFile)) { fileDialog.setSelectedFile(new File(lastChosenFile)); } - fileDialog.setFileFilter(this.getFileFilter()); + fileDialog.setFileFilter(getFileFilter()); int dialogResult = fileDialog.showOpenDialog(InternalDialog.getAWTContext()); @@ -53,7 +52,7 @@ public abstract class ThreadOpenFile extends Thread { lastChosenFile = f.getAbsolutePath(); } - this.parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult); + parentScreen.onFileOpenDialogClosed(fileDialog, dialogResult); } /**