How to debug Java Swing Layouts

前端 未结 3 1065
暖寄归人
暖寄归人 2020-12-01 17:02

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

3条回答
  •  天涯浪人
    2020-12-01 17:30

    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.

提交回复
热议问题