d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Java Swt Listener Question
Add Reply New Topic New Poll
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
May 17 2012 06:12am
I want to perform action when anything in view is pressed (includes shell, composite, buttons, labels etc) is there way to do it with single listener, or do I need to add listener for each element shown?

Code

.addListener(SWT.MouseDown, new Listener() {
         public void handleEvent(Event e) {
           //do things
            }
        });


Thanks.
Member
Posts: 32,925
Joined: Jul 23 2006
Gold: 3,804.50
May 17 2012 06:16am
you could reuse the same listener if you use an internal/external class instead of an anonymous class. but yes you have to attach it to every gui component
Member
Posts: 8,635
Joined: Dec 28 2007
Gold: 87.00
May 17 2012 06:22am
Quote (carteblanche @ 17 May 2012 14:16)
you could reuse the same listener if you use an internal/external class instead of an anonymous class. but yes you have to attach it to every gui component


thats what I thought but wanted to be sure, thanks.
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll