11package com .javadeobfuscator .deobfuscator .ui ;
22
3- import java .awt .Color ;
43import java .awt .Dialog ;
54import java .awt .Dimension ;
65import java .awt .FlowLayout ;
3332import java .util .stream .IntStream ;
3433
3534import javax .swing .*;
36- import javax .swing .border .MatteBorder ;
3735import javax .swing .border .TitledBorder ;
3836
3937import com .github .weisj .darklaf .LafManager ;
@@ -60,7 +58,6 @@ public class SwingWindow
6058 public static Transformers trans ;
6159 private static Config config ;
6260 private static List <Class <?>> transformers ;
63- private static JMenu menu ;
6461 private static JCheckBoxMenuItem shouldLimitLines ;
6562 private static JCheckBoxMenuItem storeConfigOnClose ;
6663 private static JCheckBoxMenuItem enableDarkLaf ;
@@ -92,15 +89,13 @@ public static void main(String[] args)
9289 try
9390 {
9491 UIManager .setLookAndFeel (UIManager .getSystemLookAndFeelClassName ());
95- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e2 )
92+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException e )
9693 {
97- e2 .printStackTrace ();
94+ e .printStackTrace ();
9895 }
99- ThemeSettings .getInstance ().setConfiguration (GuiConfig .getDarklafSettings ());
10096 if (GuiConfig .isDarkLaf ())
10197 {
102- LafManager .install ();
103- ThemeSettings .getInstance ().apply ();
98+ installDarkLaf ();
10499 }
105100 loadWrappers ();
106101 List <ConfigItem > fields = new SwingConfiguration (config .get ()).fieldsList ;
@@ -113,7 +108,7 @@ public static void main(String[] args)
113108
114109 //Menu
115110 JMenuBar menuBar = new JMenuBar ();
116- menu = new JMenu (GuiConfig . isDarkLaf () ? " Options" : "Options" );
111+ JMenu menu = new JMenu ("Options" );
117112 menuBar .add (menu );
118113 shouldLimitLines = new JCheckBoxMenuItem ("Limit Console Lines" );
119114 menu .add (shouldLimitLines );
@@ -124,11 +119,9 @@ public static void main(String[] args)
124119 @ Override
125120 public void actionPerformed (ActionEvent e )
126121 {
127- if (enableDarkLaf .getState ())
122+ if (enableDarkLaf .isSelected ())
128123 {
129- LafManager .install ();
130- menu .setText (" Options" );
131- ThemeSettings .getInstance ().apply ();
124+ installDarkLaf ();
132125 GuiConfig .setDarkLaf (true );
133126 } else
134127 {
@@ -137,7 +130,7 @@ public void actionPerformed(ActionEvent e)
137130 JOptionPane .YES_NO_OPTION );
138131 if (i != JOptionPane .YES_OPTION )
139132 {
140- enableDarkLaf .setState (true );
133+ enableDarkLaf .setSelected (true );
141134 return ;
142135 }
143136 GuiConfig .setDarkLaf (false );
@@ -146,25 +139,22 @@ public void actionPerformed(ActionEvent e)
146139 }
147140 }
148141 });
149- enableDarkLaf .setState (GuiConfig .isDarkLaf ());
150142 menu .add (enableDarkLaf );
151143 JMenuItem theme = new JMenuItem (new AbstractAction ("DarkLaf Theme Options" )
152144 {
153145 @ Override
154146 public void actionPerformed (ActionEvent e )
155147 {
156- if (!enableDarkLaf .getState ())
148+ if (!enableDarkLaf .isSelected ())
157149 {
158150 int i = JOptionPane .showConfirmDialog (frame , "To see DarkLaf Theme Options, DarkLaf Theme needs to be enabled first.\n " +
159151 "Enable DarkLaf Theme?" , "Enable DarkLaf Theme?" , JOptionPane .YES_NO_OPTION );
160152 if (i != JOptionPane .YES_OPTION )
161153 {
162154 return ;
163155 }
164- LafManager .install ();
165- menu .setText (" Options" );
166- ThemeSettings .getInstance ().apply ();
167- enableDarkLaf .setState (true );
156+ installDarkLaf ();
157+ enableDarkLaf .setSelected (true );
168158 GuiConfig .setDarkLaf (true );
169159 }
170160 ThemeSettings .showSettingsDialog (frame , Dialog .ModalityType .APPLICATION_MODAL );
@@ -174,9 +164,9 @@ public void actionPerformed(ActionEvent e)
174164 frame .setJMenuBar (menuBar );
175165
176166 //GuiConfig
177- shouldLimitLines .setState (GuiConfig .isLimitConsoleLines ());
178- storeConfigOnClose .setState (GuiConfig .getStoreConfigOnClose ());
179- enableDarkLaf .setState (GuiConfig .isDarkLaf ());
167+ shouldLimitLines .setSelected (GuiConfig .isLimitConsoleLines ());
168+ storeConfigOnClose .setSelected (GuiConfig .getStoreConfigOnClose ());
169+ enableDarkLaf .setSelected (GuiConfig .isDarkLaf ());
180170
181171 //Deobfuscator Input
182172 JPanel inputPnl = new JPanel ();
@@ -878,7 +868,7 @@ public void keyPressed(KeyEvent event)
878868 loadConfigFrame .getContentPane ().add (scrollPane , gbc );
879869 }
880870
881- JButton submitButton = new JButton ("Submit " );
871+ JButton submitButton = new JButton ("Load " );
882872 {
883873 GridBagConstraints gbc = new GridBagConstraints ();
884874 gbc .insets = new Insets (0 , 0 , 10 , 5 );
@@ -974,9 +964,6 @@ public void keyPressed(KeyEvent event)
974964 newFrame .setTitle ("Console" );
975965 area .setEditable (false );
976966 JScrollPane outputScrollPane = new JScrollPane (area );
977- if (enableDarkLaf .getState ()) {
978- outputScrollPane .setBorder (new MatteBorder (0 , 8 , 8 , 8 , Color .DARK_GRAY ));
979- }
980967 newFrame .getContentPane ().add (outputScrollPane );
981968 newFrame .pack ();
982969 newFrame .setSize (800 , 600 );
@@ -1117,12 +1104,22 @@ public void windowClosing(WindowEvent e)
11171104 frame .setVisible (true );
11181105 }
11191106
1107+ private static void installDarkLaf ()
1108+ {
1109+ ThemeSettings .getInstance ().setConfiguration (GuiConfig .getDarklafSettings ());
1110+ LafManager .install ();
1111+ ThemeSettings .getInstance ().apply ();
1112+ }
1113+
11201114 private static void writeAndSaveGuiConfig (List <ConfigItem > fields )
11211115 {
1122- GuiConfig .setLimitConsoleLines (shouldLimitLines .getState ());
1123- GuiConfig .setStoreConfigOnClose (storeConfigOnClose .getState ());
1116+ GuiConfig .setLimitConsoleLines (shouldLimitLines .isSelected ());
1117+ GuiConfig .setStoreConfigOnClose (storeConfigOnClose .isSelected ());
11241118 GuiConfig .setConfig (createConfig (fields , transformerSelected ));
1125- GuiConfig .setDarklafSettings (ThemeSettings .getInstance ().exportConfiguration ());
1119+ if (GuiConfig .isDarkLaf ())
1120+ {
1121+ GuiConfig .setDarklafSettings (ThemeSettings .getInstance ().exportConfiguration ());
1122+ }
11261123 GuiConfig .save ();
11271124 }
11281125
0 commit comments