Hi All,
I need to get all the components in a JFrame.
I will explain the issue in a proper way...
" I have a JFrame and added many JPanels in the frame. And the JPanel may contain other JPanel or JButton or JLabel or JTable. I need to get all the components in the frame recursively." (Because I needed to add Listener interface to all the components in the JFrame).
I used the method getComponents() on the frame and then apply this method again on each element of Component [] (after down casting the Component to Container), but this did not work correctly. Is there any way to get all the components from the top level container.
> I used the method getComponents() on the frame and then apply this method again on each element of Component [] (after down casting the Component to Container), but this did not work correctly.
In the above code I am getting all the components in the frame in Component[], components1 and then I use the method getComponents() on each element of the components1 array and then I downcast it to Container and then set MouseListenr to each element.
But the problem is I need to get all the components from the Top Container(that is the frame).
Is there any way to get all elements using any recursive method or such.