Skip to content

Commit 8ed76b9

Browse files
committed
Make FallbackException's manual jar file choosing use JFXFileChooser
1 parent 96fe38c commit 8ed76b9

File tree

2 files changed

+34
-16
lines changed

2 files changed

+34
-16
lines changed

src/java/com/javadeobfuscator/deobfuscator/ui/SwingWindow.java

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -98,17 +98,7 @@ public void run()
9898
@Override
9999
public void run()
100100
{
101-
try
102-
{
103-
SynchronousJFXCaller.init();
104-
} catch (NoClassDefFoundError e)
105-
{
106-
e.printStackTrace();
107-
ensureSwingLafLoaded();
108-
ExceptionUtil.showFatalError("You need a JVM with JavaFX (non-headless installation).\n\n" +
109-
"Could not find class " + e.getMessage());
110-
System.exit(1);
111-
}
101+
initJFX();
112102
}
113103
};
114104
GuiConfig.read();
@@ -1232,6 +1222,21 @@ public void windowClosing(WindowEvent e)
12321222
frame.setVisible(true);
12331223
}
12341224

1225+
public static void initJFX()
1226+
{
1227+
try
1228+
{
1229+
SynchronousJFXCaller.init();
1230+
} catch (NoClassDefFoundError e)
1231+
{
1232+
e.printStackTrace();
1233+
ensureSwingLafLoaded();
1234+
ExceptionUtil.showFatalError("You need a JVM with JavaFX (non-headless installation).\n\n" +
1235+
"Could not find class " + e.getMessage());
1236+
System.exit(1);
1237+
}
1238+
}
1239+
12351240
public static synchronized void ensureSwingLafLoaded()
12361241
{
12371242
if (!swingLafLoaded)

src/java/com/javadeobfuscator/deobfuscator/ui/util/FallbackException.java

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.awt.GridBagConstraints;
44
import java.awt.GridBagLayout;
55
import java.awt.Insets;
6+
import java.io.File;
67

78
import javax.swing.JButton;
89
import javax.swing.JFileChooser;
@@ -13,6 +14,8 @@
1314
import javax.swing.JTextField;
1415

1516
import com.javadeobfuscator.deobfuscator.ui.SwingWindow;
17+
import com.javadeobfuscator.deobfuscator.ui.component.SynchronousJFXFileChooser;
18+
import javafx.stage.FileChooser;
1619

1720
public class FallbackException extends Exception
1821
{
@@ -23,6 +26,7 @@ public FallbackException(String title, String msg, Throwable cause)
2326
super(msg, cause);
2427
this.printStackTrace();
2528
SwingWindow.ensureSwingLafLoaded();
29+
SwingWindow.initJFX();
2630
JPanel fallback = new JPanel();
2731
fallback.setLayout(new GridBagLayout());
2832
GridBagConstraints gbc = new GridBagConstraints();
@@ -46,12 +50,21 @@ public FallbackException(String title, String msg, Throwable cause)
4650
JButton button = new JButton("Select");
4751
button.addActionListener(e ->
4852
{
49-
JFileChooser inputFile = new JFileChooser();
50-
int action = inputFile.showOpenDialog(null);
51-
if (action == JFileChooser.APPROVE_OPTION)
53+
SynchronousJFXFileChooser chooser = new SynchronousJFXFileChooser(() -> {
54+
FileChooser ch = new FileChooser();
55+
ch.setTitle("Select deobfuscator jar");
56+
ch.setInitialDirectory(new File("abc").getAbsoluteFile().getParentFile());
57+
ch.getExtensionFilters().addAll(
58+
new FileChooser.ExtensionFilter("Jar files", "*.jar"),
59+
new FileChooser.ExtensionFilter("Jar and Zip files", "*.jar", "*.zip"),
60+
new FileChooser.ExtensionFilter("Zip files", "*.zip"),
61+
new FileChooser.ExtensionFilter("All Files", "*.*"));
62+
return ch;
63+
});
64+
File file = chooser.showOpenDialog();
65+
if (file != null)
5266
{
53-
String path = inputFile.getSelectedFile().toString();
54-
textField.setText(path);
67+
textField.setText(file.getAbsolutePath());
5568
}
5669
});
5770
GridBagConstraints gbc_Button = new GridBagConstraints();

0 commit comments

Comments
 (0)