how to access the jpanel and other components on click of a button
hi ,
need help,how to access the components of a frame onclick of a button ,if the actionPerformed() is written in a seperate class.
in my code
button.addActionListener(new Xyz());
Xyz is implementing the ActionListener.
in actionPerformed() i want to access the components in the frame.
thanks.
[341 byte] By [
murtya] at [2007-10-3 3:40:58]

public class Xyz implements ActionListener{
JFrame frame;
Component[] comps;
public Xyz(JFrame f){
frame = f;
comps = frame.getContentPane().getComponents();
}
public void actionPerformed(ActionEvent e){
// access elements in comps array
}
}
button.addActionListener(new Xyz(this)); // if 'this' is a JFrame in question
hiwaa at 2007-7-14 21:36:44 >
