i want to realize a messaging system over a custom-created listener model
to use only the very basics of a listener pattern, i want to create them right off from zero point, without using component listeners/ action listener
so heres my first try :
public interface MyListener
{
public void notifyit(Object e);
}
class MrMoo
{
MyListener listener;
public MyListener getListener()
{
return listener;
}
public void addListener(MyListener l)
{
if(l!=null) listener = l;
}
public void removeListener()
{
listener = null;
}
public void doit()
{
listener.notifyit(this);
}
}
public class ListenerTest
{
public static void main(String args[])
{
MrMoo m = new MrMoo();
MyListener l = new MyListener()
{
public void notifyit(Object e)
{
System.out.println("!!!");
}
};
m.addListener(l);
m.doit();
}
}
i need some response if im on the right way, if there could be done something better etc