Java action listener question?

I normally prefer EventBus for those kinds of Events.

Up vote 0 down vote favorite share g+ share fb share tw.

I am creating a custom JPanel element (a login form). I want to allow people who use my panel to subscribe/listen to an event called "loginSuccessful". What is the best way to implement this in my JPanel object?

UPDATE: oh and I also want to add that when that action is triggered, I also want to return a "User" object containing the person that was just logged in java swing actionlistener link|improve this question edited Aug 12 '10 at 19:53jjnguy?37.9k1287173 asked Aug 12 '10 at 19:47whydna753214 76% accept rate.

I normally prefer EventBus for those kinds of Events. Library and Examples can be found here Moreover you should consider to keep businesslogic out of your viewclass (panel) and create some kind of LoginController for your loginbusinesslogic. There are plenty of good examples out there.

EDIT: You can send an UserObject within an EventBusEvent as well.

Thanks for the link, I didn't know about the EventBus and it may prove to be just what I needed right about now. – Stephen P Aug 12 '10 at 20:46.

I would start by separating your code form widget code. Don't extend where you don't need to. Where classes are focussed on a particular job, everything becomes so much easier.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions