@@ -67,7 +67,8 @@ public class Debugger extends JFrame
6767 private JTabbedPane tabbedPane ;
6868 private boolean showAllFields = false ;
6969 private boolean showAllMethods = false ;
70- private static final String VERSION = "beta-1.0" ;
70+ private static boolean isOnTop = false ;
71+ private static final String VERSION = "beta-1.1" ;
7172
7273 public Debugger ()
7374 {
@@ -93,7 +94,10 @@ public Debugger()
9394 viewMenu .add (enableBreakpointsItem );
9495 viewMenu .addSeparator ();
9596 JCheckBoxMenuItem onTopItem = new JCheckBoxMenuItem ("Always on top" );
96- onTopItem .addActionListener (a -> setAlwaysOnTop (!isAlwaysOnTop ()));
97+ onTopItem .addActionListener (a -> {
98+ isOnTop = !isOnTop ;
99+ setAlwaysOnTop (!isAlwaysOnTop ());
100+ });
97101 viewMenu .add (onTopItem );
98102 menuBar .add (viewMenu );
99103
@@ -122,7 +126,7 @@ public Debugger()
122126 dumpClassItem .addActionListener (a -> {
123127 JFrame newFrame = new JFrame ();
124128 newFrame .setTitle ("Dump Resource" );
125- newFrame .setBounds (100 , 100 , 500 , 250 );
129+ newFrame .setBounds (100 , 100 , 500 , 260 );
126130 newFrame .setResizable (true );
127131 newFrame .getContentPane ().setLayout (new GridBagLayout ());
128132
@@ -174,11 +178,19 @@ public void actionPerformed(ActionEvent e)
174178 selectButtonC .gridx = 1 ;
175179 newFrame .getContentPane ().add (selectButton , selectButtonC );
176180
181+ JCheckBox tabIsLoader = new JCheckBox ("Tab Selected is ClassLoader" );
182+ GridBagConstraints tabIsLoaderC = new GridBagConstraints ();
183+ tabIsLoaderC .insets = new Insets (2 , 10 , 5 , 10 );
184+ tabIsLoaderC .gridy = 3 ;
185+ tabIsLoaderC .fill = GridBagConstraints .BOTH ;
186+ newFrame .getContentPane ().add (tabIsLoader , tabIsLoaderC );
187+
177188 JButton submit = new JButton ("Dump" );
178189 GridBagConstraints submitC = new GridBagConstraints ();
179190 submitC .insets = new Insets (0 , 0 , 10 , 0 );
180191 submitC .anchor = GridBagConstraints .SOUTH ;
181- submitC .gridy = 3 ;
192+ submitC .gridy = 4 ;
193+ submitC .gridwidth = 2 ;
182194 submitC .weightx = 1 ;
183195 submitC .weighty = 1 ;
184196 newFrame .getContentPane ().add (submit , submitC );
@@ -187,7 +199,12 @@ public void actionPerformed(ActionEvent e)
187199 {
188200 ClassLoader loader = null ;
189201 if (tabbedPane .getSelectedIndex () > 0 )
190- loader = instances .get (tabbedPane .getSelectedIndex () - 1 ).clazz .getClassLoader ();
202+ {
203+ if (tabIsLoader .isSelected ())
204+ loader = (ClassLoader )instances .get (tabbedPane .getSelectedIndex () - 1 ).instance ;
205+ else
206+ loader = instances .get (tabbedPane .getSelectedIndex () - 1 ).clazz .getClassLoader ();
207+ }
191208 InputStream stream ;
192209 if (loader == null )
193210 stream = getClass ().getResourceAsStream (textField .getText ());
@@ -215,6 +232,7 @@ public void actionPerformed(ActionEvent e)
215232 Toolkit toolkit = Toolkit .getDefaultToolkit ();
216233 Dimension screenSize = toolkit .getScreenSize ();
217234 newFrame .setLocation ((screenSize .width - newFrame .getWidth ()) / 2 , (screenSize .height - newFrame .getHeight ()) / 2 );
235+ newFrame .setAlwaysOnTop (isOnTop );
218236 newFrame .setVisible (true );
219237 });
220238 dumpClassItem .setToolTipText ("Dump class using one of the selected ClassLoaders" );
@@ -224,7 +242,7 @@ public void actionPerformed(ActionEvent e)
224242 loadClassItem .addActionListener (a -> {
225243 JFrame newFrame = new JFrame ();
226244 newFrame .setTitle ("Load Class" );
227- newFrame .setBounds (100 , 100 , 500 , 200 );
245+ newFrame .setBounds (100 , 100 , 500 , 230 );
228246 newFrame .setResizable (true );
229247 newFrame .getContentPane ().setLayout (new GridBagLayout ());
230248
@@ -244,11 +262,18 @@ public void actionPerformed(ActionEvent e)
244262 textFieldC .fill = GridBagConstraints .BOTH ;
245263 newFrame .getContentPane ().add (textField , textFieldC );
246264
265+ JCheckBox tabIsLoader = new JCheckBox ("Tab Selected is ClassLoader" );
266+ GridBagConstraints tabIsLoaderC = new GridBagConstraints ();
267+ tabIsLoaderC .insets = new Insets (2 , 10 , 5 , 10 );
268+ tabIsLoaderC .gridy = 2 ;
269+ tabIsLoaderC .fill = GridBagConstraints .BOTH ;
270+ newFrame .getContentPane ().add (tabIsLoader , tabIsLoaderC );
271+
247272 JButton submit = new JButton ("Submit" );
248273 GridBagConstraints submitC = new GridBagConstraints ();
249274 submitC .insets = new Insets (0 , 0 , 10 , 0 );
250275 submitC .anchor = GridBagConstraints .SOUTH ;
251- submitC .gridy = 2 ;
276+ submitC .gridy = 3 ;
252277 submitC .weightx = 1 ;
253278 submitC .weighty = 1 ;
254279 newFrame .getContentPane ().add (submit , submitC );
@@ -257,7 +282,12 @@ public void actionPerformed(ActionEvent e)
257282 {
258283 ClassLoader loader = null ;
259284 if (tabbedPane .getSelectedIndex () > 0 )
260- loader = instances .get (tabbedPane .getSelectedIndex () - 1 ).clazz .getClassLoader ();
285+ {
286+ if (tabIsLoader .isSelected ())
287+ loader = (ClassLoader )instances .get (tabbedPane .getSelectedIndex () - 1 ).instance ;
288+ else
289+ loader = instances .get (tabbedPane .getSelectedIndex () - 1 ).clazz .getClassLoader ();
290+ }
261291 DebuggerHook .injectDebugger (textField .getText (), null , loader );
262292 }catch (Exception e )
263293 {
@@ -269,6 +299,7 @@ public void actionPerformed(ActionEvent e)
269299 Toolkit toolkit = Toolkit .getDefaultToolkit ();
270300 Dimension screenSize = toolkit .getScreenSize ();
271301 newFrame .setLocation ((screenSize .width - newFrame .getWidth ()) / 2 , (screenSize .height - newFrame .getHeight ()) / 2 );
302+ newFrame .setAlwaysOnTop (isOnTop );
272303 newFrame .setVisible (true );
273304 });
274305 loadClassItem .setToolTipText ("Load class to Debugger. Only static fields will be editable" );
@@ -450,6 +481,7 @@ public static void showErrorDialog(String message, Exception e)
450481 Toolkit toolkit = Toolkit .getDefaultToolkit ();
451482 Dimension screenSize = toolkit .getScreenSize ();
452483 newFrame .setLocation ((screenSize .width - newFrame .getWidth ()) / 2 , (screenSize .height - newFrame .getHeight ()) / 2 );
484+ newFrame .setAlwaysOnTop (isOnTop );
453485 newFrame .setVisible (true );
454486 }
455487
@@ -1399,7 +1431,7 @@ public void mousePressed(MouseEvent e)
13991431 scrollPane .setBorder (BorderFactory .createEmptyBorder ());
14001432 scrollPane .getViewport ().setBackground (Color .WHITE );
14011433 newFrame .add (scrollPane , treeC );
1402-
1434+ newFrame . setAlwaysOnTop ( isOnTop );
14031435 newFrame .setVisible (true );
14041436 }
14051437 }
@@ -2089,7 +2121,7 @@ else if(type.isPrimitive())
20892121 setValueC .weighty = 1 ;
20902122 setValueC .gridy = 4 ;
20912123 newFrame .add (setValue , setValueC );
2092-
2124+ newFrame . setAlwaysOnTop ( isOnTop );
20932125 newFrame .setVisible (true );
20942126 }
20952127 }
@@ -3050,7 +3082,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
30503082 actions .add (edit );
30513083
30523084 panel .add (actions , BorderLayout .PAGE_END );
3053- if (JOptionPane .showConfirmDialog (null , panel , "Edit Array" ,
3085+ if (JOptionPane .showConfirmDialog (Debugger . this , panel , "Edit Array" ,
30543086 JOptionPane .OK_CANCEL_OPTION , JOptionPane .PLAIN_MESSAGE ) == JOptionPane .OK_OPTION )
30553087 {
30563088 this .array = Array .newInstance (type , values .size ());
0 commit comments