views:

15

answers:

1

Hi, I'm trying to modify an existing application using AWT for dialogs, etc. I don't know all the code of the application, so I'm not sure how are the objects stacked.

I tried adding a new JButton to a JPanel with no layout. I set location and size, validated, repainted... and nothing is displayed. Now I'm a bit lost - how do I figure out why this happened? Is there some way to poke around a live application window and see the AWT objects tree? How do I approach this kind of problems?

Disclaimer: I know next to nothing about AWT.

A: 

Logging! Making log calls whenever you're manipulating anything on the AWT stack. Most (all?) AWT objects also have decent toString methods, so it's possible to get and print objects in a component and get meaningful debugging information (i.e. for(Component c : frame.getComponents()) { System.err.println(c.toString()); } ).

matiasf
That worked. Apparently some unrelated component was removing all objects (including my new one).
viraptor