Archive

Posts Tagged ‘debugging’

Debugging GUI events

September 22nd, 2009

Debugging gui events is usually not possible with regular line per line debugging and is done mostly by tracing.
For debugging code that relies on Java swing events like drag and drop, mouse moving, etc., having something similar to code below is very useful:

 
public boolean isMouseAboveHeaderPanel() {
System.out.println("HeaderPanel.isMouseAboveHeaderPanel() called from: "
+ Thread.currentThread().getStackTrace()[2].getClassName() + "."
+ Thread.currentThread().getStackTrace()[2].getMethodName());
 
// ...
 
}

In this way you trace not only current function but also you got information from where you entered that function. Of course to make things easier you should make some kind of a shortcut for entering this trace line. In Eclipse you can do that with code template:

System.out.println("${enclosing_type}.${enclosing_method}() called from: "
+ Thread.currentThread().getStackTrace()[2].getClassName() + "." 
+ Thread.currentThread().getStackTrace()[2].getMethodName());

This helped me in lot of situations, I hope that it will help you as well.

Share/Save/Bookmark

General, Java , ,

Javascript Environment Tips

October 10th, 2008

One may think that if he or she wants to work “professionally” with Ajax and Javascript that he will gonna need a comprehensive IDE that enables “fancy” features.

But, in this case, you can do everything well and with great efficiency if you stick to Firebug and its built-in Javascript debugging tools. Of course, you should have a text editor with syntax highlighting at least. (We recommend Notepad++).

The instructions on how to use Firebug for debugging Javascript can be found here.

Share/Save/Bookmark

Javascript , , , ,