I want to create a listener that allows me to execute code in a JPanel
when it is made visible to the user or hidden. Sometimes called the panel within a JDialog
or directly the JFrame
main. I am trying with this:
ComponentListener c = new ComponentAdapter() {
@Override
public void componentShown(ComponentEvent e) {
JOptionPane.showMessageDialog(null, "revisar si se actualizan comoponente. ");
}
};
this.addComponentListener(c);
But I don't get the desired result.
Update
I am using this class for my panels:
public abstract class JPanelBase extends JPanel{
JPanelBase(){
//AQUÍ DEFINO MI EVENTO...
}
//AQUI MIS OPERACIONES....
}
Well, I found the answer in the English forum here.
And this was my implementation: