Save a reference to them that you can use later to refer to them.
|
Code:
|
class Pseudo {
JTextField textField;
JButton button = new JButton("hi");
private void buildUI() {
testField = new JTextField(12);
JPanel panel = new JPanel(someLayout);
panel.add(textField);
panel.add(button);
}
} |
Or you can use the Container methods like
getComponents to access them.
|
Code:
|
Component[] c = panel.getComponents();
for(int i = 0; i < c.length; i++) {
System.out.println(c[i].getClass().getSimpleName());
} |