Please help me, I'm a newbie too!
Hi all,
I think that my question is stupid, but I don't know how to solve it.
I have a class A like this:
import javax.swing.JFrame;
publicclass Aextends JFrame{
private BButton bb =null;
public A(){
super("Passing class...");
bb =new BButton();
getContentPane().add(bb);
pack();
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
publicstaticvoid main(String[] args){
new A();
}
}
that use the following class:
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
publicclass BButtonextends JButton{
public BButton(){
super("Please Click me!");
addActionListener(new ActionListener(){
publicvoid actionPerformed(ActionEvent ae){
System.out.println("Clicked, but from who?");
}
});
}
}
My trouble is: how can BButton knows which class istanciated it? In other words, in the BButton point of view, how can it know that was class A to istanciated it?
Thanks in advance.
Pier@

