Getting JComponents

Hi! How can I get the JComponentes of a GUI? With AWT it's easy, I just have to type Component comp=this.getComponent(1); But how does this work with swing? There isnt't a method like getJComponents(). Bye, Nick

Thank you. But now I have the next problem. I can't read out the array of getComponents() in an other method: ... public Text(List list, int gaps) { this.gaps=gaps; setLayout(new FlowLayout()); it=list.iterator(); while (it.hasNext()) { add(new JLabel((String)it.next())); if (it.hasNext()) add(new JTextField("",7)); } } ... public List readout() { Component comp[]=this.getComponents(); for(int i=1; i<2*gaps; i=i+2) {JTextField jtext=(JTextField)comp[i]; result.add(jtext.getText()); } return result; } This doesn't work, the List result is empty. How can I get access to the JTextField Components and their content, in an other method where they were created?

Then you arn't doing something right... I can't tell what the 'gaps' variable is supposed to do in your component, but you should be looping through the entire array you get back from 'getComponents()' not '2*gaps'. Here is a short example that shows that this works :