The Source for Java Technology Collaboration
User: Password:



Alexander Potochkin

Alexander Potochkin's Blog

Swing testing and debugging on JavaOne

Posted by alexfromsun on June 28, 2006 at 09:40 AM | Comments (2)

Hello everybody !

After spending a fantastic after JavaOne vacation, travalling Arizona and Florida I am happy to say hello to the comminity again.
Thanks to everyone who visited JavaOne and especially who visited my BOF session about Swing testing and debugging.

I'd like to underline that it were you guys who gave me much of the ideas to complete the presentation.
Thank you once again and let me add two little debugging-related addons which I didn't mention earlier:

CTRL+SHIFT+F1

I was really surprised when AWT guys told me about this funny feature, because I hadn't ever used it before.
So, this combo is hardcoded in java.awt.Window.preProcessKeyEvent() method and is used to dump the list of children of this window to System.out.

For example if you press CTRL+SHIFT+F1 when an empty JFrame is active and check the console
you'll discover the compound nature of JFrame:

javax.swing.JFrame[frame0,0,0,200x200,layout=java.awt.BorderLayout,title=,resizable,normal,defaultCloseOperation=EXIT_ON_CLOSE,rootPane=javax.swing.JRootPane[,4,28,192x168,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=],rootPaneCheckingEnabled=true]
 javax.swing.JRootPane[,4,28,192x168,layout=javax.swing.JRootPane$RootLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777673,maximumSize=,minimumSize=,preferredSize=]
  javax.swing.JPanel[null.glassPane,0,0,192x168,hidden,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=16777217,maximumSize=,minimumSize=,preferredSize=]
  javax.swing.JLayeredPane[null.layeredPane,0,0,192x168,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,optimizedDrawingPossible=true]
   javax.swing.JPanel[null.contentPane,0,0,192x168,layout=javax.swing.JRootPane$1,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=]

-Xbootclasspath

This might be a well known feature, but I'd like to mention it here despite the fact it's not related to Swing directly.
In the presentation I collected some useful debugging techniques, but what if you tried everyting and still don't find a bug?

With help of -Xbootclasspath you can substitute any core classes from JDK and add as many System.out.println as you want.

For instance:

  1. Create java/awt folders and put there the Component.java from JDK
  2. Add System.out.println(this) to the very beginning of requestFocusHelper() method
  3. Compile this class
  4. Run your application as java -Xbootclasspath/p:<path to your java/awt folder> YourApplication

After that you'll be notified when any Component.requestFocusXXX() is invoked

This technique is very helpful for our dear JDK contributors, because it makes it so easy to test updated JDK on any OS with the installed JDK remains intact

Afterword

Don't forget to check out SwingHelper project
and send your valuable comments either to the project's mailing lists or leave it here.

Please share your ideas how to make Swing testing and debugging easier
and what we should add to the next version of JDK to prevent Swing programmers from all that tricky bugs !


Bookmark blog post: del.icio.us del.icio.us Digg Digg DZone DZone Furl Furl Reddit Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment

  • CTRL+SHIFT+F1

    Funny, but I thought I raised my hand and mentioned that one during or after the BOF.

    Well at least one of them actually wrote it so they deserve more credit than me. :-D

    Enjoyed the presentation at JavaOne.

    Kind Regards,

    Ed

    Posted by: cupofjoe on June 28, 2006 at 03:51 PM

  • Hello Ed

    Nice to see you here !
    I definitely remember that you mentioned this trick during the BOF,
    I was really surprised that someone new about that.

    During BOF preparation AWT guys told me this combo (no lie:-) ) and
    I was going to mention it in the session,
    but decided not to make one more slide because of time restrictions

    See you
    alexp

    Posted by: alexfromsun on June 29, 2006 at 06:08 AM



Only logged in users may post comments. Login Here.


Powered by
Movable Type 3.01D
 Feed java.net RSS Feeds