Does Java have built-in methods for displaying the number of components in a container? For example, there is a JFrame. Several components have been added to it. How to find out the number of these components? So far only alternate transfer of focus comes to mind with checking the component index (it is different for each component). That is, we find the maximum index. Perhaps there is some built-in method for finding the number of components in a container?

  • farame.getComponentCount (); - returns the number of components. Or a question in the search for the number of components sorted by type? - Peter Slusar
  • The question is in the number of all components. I thought maybe the .getComponentCount () method is designed for something else, since I have 3 components in the container, and everything is displayed correctly, and the method call .getComponentCount () returns 1. Although I have to go 3. - Nikolai
  • This is how the application itself looks like: link - Nikolay
  • one
    in the list of components, the JFrame component has 1 (probably a kind of panel), and already on the Panel, suppose buttons are already stored. etc - Peter Slusar
  • The fact of the matter is that I first add the menu to JFrame, then JToolBar and only then the JPanel panel itself. Therefore, there should be 3 components. Program listing: link - Nikolay

0