@@ -319,7 +319,7 @@ public void actionPerformed(ActionEvent e)
319319 @ Override
320320 public void windowClosing (WindowEvent we )
321321 {
322- int dialogResult = JOptionPane .showConfirmDialog (null , "Do you want to close the main program?" ,
322+ int dialogResult = JOptionPane .showConfirmDialog (Debugger . this , "Do you want to close the main program?" ,
323323 "Debugger" , JOptionPane .YES_NO_CANCEL_OPTION );
324324 if (dialogResult == JOptionPane .YES_OPTION )
325325 System .exit (0 );
@@ -1014,7 +1014,7 @@ public void mousePressed(MouseEvent mouseEvent)
10141014 JLabel text = new JLabel ("Value: " );
10151015 innerPnl .add (text );
10161016 ListButton arrButton = new ListButton ("Edit Array" , Array .newInstance (clazz .getComponentType (),
1017- 0 ), clazz .getComponentType ());
1017+ 0 ), clazz .getComponentType (), panel );
10181018 innerPnl .add (arrButton );
10191019 JCheckBox nullBox = new JCheckBox ("Null" );
10201020 nullBox .addActionListener (a -> {
@@ -1156,7 +1156,7 @@ else if(Enum.class.isAssignableFrom(method.getParameterTypes()[i]))
11561156 accessible = enumFields .get (comboBox .getSelectedIndex ()).isAccessible ();
11571157 modifier = enumFields .get (comboBox .getSelectedIndex ()).getModifiers ();
11581158 enumFields .get (comboBox .getSelectedIndex ()).setAccessible (true );
1159- modifiersField .setInt (enumFields .get (comboBox .getSelectedIndex ()),
1159+ modifiersField .setInt (enumFields .get (comboBox .getSelectedIndex ()),
11601160 enumFields .get (comboBox .getSelectedIndex ()).getModifiers () & ~Modifier .FINAL );
11611161 args .add (enumFields .get (comboBox .getSelectedIndex ()).get (null ));
11621162 enumFields .get (comboBox .getSelectedIndex ()).setAccessible (accessible );
@@ -1504,17 +1504,21 @@ public void mousePressed(MouseEvent mouseEvent)
15041504 newFrame .setResizable (true );
15051505 newFrame .getContentPane ().setLayout (new GridBagLayout ());
15061506
1507+ Data data = (Data )table .getValueAt (table .getSelectedRow (), 2 );
1508+ boolean isField = data .data [1 ] instanceof Field ;
1509+ Class <?> type = isField ? ((Field )data .data [1 ]).getType ()
1510+ : ((Class <?>)data .data [4 ]).getComponentType ();
1511+
15071512 GridBagConstraints ownerLabelC = new GridBagConstraints ();
15081513 ownerLabelC .insets = new Insets (10 , 10 , 0 , 0 );
15091514 ownerLabelC .anchor = GridBagConstraints .NORTHWEST ;
15101515 ownerLabelC .fill = GridBagConstraints .HORIZONTAL ;
15111516 ownerLabelC .weightx = 1 ;
1512- newFrame .add (new JLabel ("Owner: " + ((Class <?>)((Data )table .
1513- getValueAt (table .getSelectedRow (), 2 )).data [0 ]).getName ()), ownerLabelC );
1514- Data data = (Data )table .getValueAt (table .getSelectedRow (), 2 );
1515- boolean isField = data .data [1 ] instanceof Field ;
1516- Class <?> type = isField ? ((Field )data .data [1 ]).getType ()
1517- : ((Class <?>)data .data [4 ]).getComponentType ();
1517+ if (isField )
1518+ newFrame .add (new JLabel ("Owner: " + ((Field )data .data [1 ]).getDeclaringClass ().getName ()), ownerLabelC );
1519+ else
1520+ newFrame .add (new JLabel ("Owner: " + ((Class <?>)((Data )table .
1521+ getValueAt (table .getSelectedRow (), 2 )).data [0 ]).getName ()), ownerLabelC );
15181522 if (isField )
15191523 {
15201524 GridBagConstraints accessModC = new GridBagConstraints ();
@@ -1552,8 +1556,9 @@ public void mousePressed(MouseEvent mouseEvent)
15521556 accessible = ((Field )data .data [1 ]).isAccessible ();
15531557 ((Field )data .data [1 ]).setAccessible (true );
15541558 }
1555- value = isField ? ((Field )data .data [1 ]).get (data .data [2 ]) : Array .get (data .data [1 ],
1556- (int )data .data [2 ]);
1559+ if (table .getValueAt (table .getSelectedRow (), 0 ) != null )
1560+ value = isField ? ((Field )data .data [1 ]).get (data .data [2 ]) : Array .get (data .data [1 ],
1561+ (int )data .data [2 ]);
15571562 if (isField )
15581563 ((Field )data .data [1 ]).setAccessible (accessible );
15591564 }catch (Exception e )
@@ -1570,6 +1575,8 @@ public void mousePressed(MouseEvent mouseEvent)
15701575 newFrame .add (panel , panelC );
15711576 JCheckBox nullBox = new JCheckBox ("Null" );
15721577 JButton setValue = new JButton ("Set Value" );
1578+ if (table .getValueAt (table .getSelectedRow (), 0 ) == null )
1579+ setValue .setEnabled (false );
15731580 if (type == boolean .class || Enum .class .isAssignableFrom (type ))
15741581 {
15751582 GridBagConstraints textC = new GridBagConstraints ();
@@ -1594,7 +1601,11 @@ public void mousePressed(MouseEvent mouseEvent)
15941601 enumFields .add (f );
15951602 for (Field f : enumFields )
15961603 comboBox .addItem (f .getName ());
1597- if (value == null )
1604+ if (table .getValueAt (table .getSelectedRow (), 0 ) == null )
1605+ {
1606+ nullBox .setEnabled (false );
1607+ comboBox .setEnabled (false );
1608+ }else if (value == null )
15981609 {
15991610 nullBox .setSelected (true );
16001611 comboBox .setEnabled (false );
@@ -1771,16 +1782,19 @@ public void mousePressed(MouseEvent mouseEvent)
17711782 textC .anchor = GridBagConstraints .NORTHWEST ;
17721783 textC .insets = new Insets (3 , 0 , 10 , 0 );
17731784 panel .add (text , textC );
1774- ListButton arrButton = new ListButton ("Edit Array" , value == null ? Array .newInstance (type .getComponentType (),
1775- 0 ) : value ,
1776- type .getComponentType ());
1785+ ListButton arrButton = new ListButton ("Edit Array" , value == null ?
1786+ Array .newInstance (type .getComponentType (), 0 ) : value , type .getComponentType (), panel );
17771787 GridBagConstraints arrButtonC = new GridBagConstraints ();
17781788 arrButtonC .anchor = GridBagConstraints .NORTHWEST ;
17791789 arrButtonC .gridx = 1 ;
17801790 arrButtonC .weightx = 1 ;
17811791 panel .add (arrButton , arrButtonC );
17821792
1783- if (value == null )
1793+ if (table .getValueAt (table .getSelectedRow (), 0 ) == null )
1794+ {
1795+ nullBox .setEnabled (false );
1796+ arrButton .setEnabled (false );
1797+ }else if (value == null )
17841798 {
17851799 nullBox .setSelected (true );
17861800 arrButton .setEnabled (false );
@@ -1916,7 +1930,11 @@ public void mousePressed(MouseEvent mouseEvent)
19161930 valueC .weightx = 1 ;
19171931 panel .add (textField , valueC );
19181932
1919- if (value == null )
1933+ if (table .getValueAt (table .getSelectedRow (), 0 ) == null )
1934+ {
1935+ nullBox .setEnabled (false );
1936+ textField .setEnabled (false );
1937+ }else if (value == null )
19201938 {
19211939 nullBox .setSelected (true );
19221940 textField .setEnabled (false );
@@ -2978,7 +2996,7 @@ private class ListButton extends JButton
29782996 {
29792997 public Object array ;
29802998
2981- public ListButton (String text , Object array , Class <?> type )
2999+ public ListButton (String text , Object array , Class <?> type , JPanel parent )
29823000 {
29833001 super (text );
29843002 this .array = array ;
@@ -3095,7 +3113,7 @@ public Component getTableCellRendererComponent(JTable table, Object value, boole
30953113 actions .add (edit );
30963114
30973115 panel .add (actions , BorderLayout .PAGE_END );
3098- if (JOptionPane .showConfirmDialog (Debugger . this , panel , "Edit Array" ,
3116+ if (JOptionPane .showConfirmDialog (parent , panel , "Edit Array" ,
30993117 JOptionPane .OK_CANCEL_OPTION , JOptionPane .PLAIN_MESSAGE ) == JOptionPane .OK_OPTION )
31003118 {
31013119 this .array = Array .newInstance (type , values .size ());
@@ -3179,7 +3197,7 @@ private Object editValueWindow(Object o, Class<?> type, boolean isAdd)
31793197 textC .insets = new Insets (3 , 0 , 10 , 0 );
31803198 panel .add (text , textC );
31813199 ListButton arrButton = new ListButton ("Edit Array" , o == null ? Array .newInstance (type .getComponentType (),
3182- 0 ) : o , type .getComponentType ());
3200+ 0 ) : o , type .getComponentType (), panel );
31833201 GridBagConstraints arrButtonC = new GridBagConstraints ();
31843202 arrButtonC .anchor = GridBagConstraints .NORTHWEST ;
31853203 arrButtonC .gridx = 1 ;
0 commit comments