Alex Rivera | Logout

How to debug Java Swing Layouts

Asked 2011-07-12T20:57:36.573
11

There is one method which prints layout information for particulat components. I knew one method is there but I forgot the name.

When you call that method for Swing component it displays layout information in detail for that component just like dumpstacktrace call.

Any idea? What is that method name? I read it in one book but forgot it. Or let me know some good ways to debug Java Swing layout.

Edit
Report

1 Answer

2

Each Container (and this includes all JComponents) has a getLayout() method which will return the layout manager that has been set for this component or null if none are set (but remember that many are given default managers). You can also getComponents() to return an array of the components held. If you want to see all layout managers, you'd have to write a recursive method to go through all the components held, check that they inherit from Container and then call the above methods.

answered 2011-07-12T21:20:28.443

Your Answer