How can I get all the components of a panel in Java Swing?

后端 未结 2 880
失恋的感觉
失恋的感觉 2021-01-17 18:38

How can I get all the components of a panel in Java Swing?

Is there any method like foreach in C# to deal all the child components of a JPanel?

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-17 19:19

    You may use the method getComponents:

    Component[] components = jpanel.getComponents();
    

提交回复
热议问题