3
3
import java .awt .GridBagConstraints ;
4
4
import java .awt .GridBagLayout ;
5
5
import java .awt .Insets ;
6
+ import java .io .File ;
6
7
7
8
import javax .swing .JButton ;
8
9
import javax .swing .JFileChooser ;
13
14
import javax .swing .JTextField ;
14
15
15
16
import com .javadeobfuscator .deobfuscator .ui .SwingWindow ;
17
+ import com .javadeobfuscator .deobfuscator .ui .component .SynchronousJFXFileChooser ;
18
+ import javafx .stage .FileChooser ;
16
19
17
20
public class FallbackException extends Exception
18
21
{
@@ -23,6 +26,7 @@ public FallbackException(String title, String msg, Throwable cause)
23
26
super (msg , cause );
24
27
this .printStackTrace ();
25
28
SwingWindow .ensureSwingLafLoaded ();
29
+ SwingWindow .initJFX ();
26
30
JPanel fallback = new JPanel ();
27
31
fallback .setLayout (new GridBagLayout ());
28
32
GridBagConstraints gbc = new GridBagConstraints ();
@@ -46,12 +50,21 @@ public FallbackException(String title, String msg, Throwable cause)
46
50
JButton button = new JButton ("Select" );
47
51
button .addActionListener (e ->
48
52
{
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 )
52
66
{
53
- String path = inputFile .getSelectedFile ().toString ();
54
- textField .setText (path );
67
+ textField .setText (file .getAbsolutePath ());
55
68
}
56
69
});
57
70
GridBagConstraints gbc_Button = new GridBagConstraints ();
0 commit comments