J1 Session Blog: Swing Debugging – Fast and Furious
The talk was given by Maxim Zakharenkov and it proved extremely interesting. Basically, he demonstrated a tool called SwingExplorer (https://swingexplorer.dev.java.net/) which Maxim is the lead developer of. If you ever had nasty Swing problems, such as layout misalignments, components not appearing, drawing mishaps, unhandled events or code not adhering to Swing conventions (e.g. calling Swing outside of the EDT) then look no further.
The session mainly consisted of a number of demonstrations. In each demo Maxim showed a typical Swing problem and then fired up SwingExplorer to debug the code and fixed the bug.
The main features of SwingExplorer are:
- Visually explore the component hierarchy and layout (e.g. SwingExplorer can show the component boundaries both with and without borders).
- Figure out when exactly each component was created (including the stack trace).
- Record, replay (both back and forth!) and inspect all the AWT events which occur while building the user interface or handling events.
- Investigate user events and what components handle which events
- Watch the ETD and find out unnecessary pauses or violations of Swing programming conventions
In one of the demos Maxim showed step by step how a radio button is drawn in Swing and the sequence of drawing instructions proved horrendously complex.
SwingExplorer is a godsend and should be included in the basic toolbox of every Swing developer.










