How to get all elements inside a JFrame?

后端 未结 4 1405
悲哀的现实
悲哀的现实 2020-11-28 10:52

I have this code to get all the elements I need and do some processing. The problem is I need to specify every panel I have to get the elements inside it.

fo         


        
4条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-28 11:25

    Look at the doc for JFrame. Everything you put in a JFrame is actually put in a root pane contained in the frame.

    for (Component c : this.getRootPane().getComponents())    
    

提交回复
热议问题