PDA

View Full Version : swing components and listeners


philski5
10-26-2002, 12:05 AM
sorry for abuse of the exclation marks, but all mine will have them this weekend because I have an exam on monday.

My question, (taken from a exam queston example):

Can a component have two different kinds of listeners? (java swing components are the components referred to).

Thanks
Phil

bwkaz
10-26-2002, 09:55 AM
As far as I know, yeah... you can attach (for example) an ActionListener and a MouseListener to one component.

But try it and see for yourself. That's the definitive answer. Write a program, and see if it compiles and runs.

Nafae
10-26-2002, 05:51 PM
Originally posted by philski5
sorry for abuse of the exclation marks, but all mine will have them this weekend because I have an exam on monday.


please note that the forum rules (http://www.coderforums.net/cfinfo.php) point out that members may not use the alert icon. I have changed your thread accordingly, please keep this in mind when creating future threads.

kmj
10-26-2002, 06:46 PM
I'll add that I highly doubt using the flashing alert icon is more likely to get your question answered; those who answer questions are here because they want to answer questions; they will look for new threads in their chosen forums and respond to them..

inkedmn
10-27-2002, 05:32 AM
yes, it's possible to have more than one listener on a component.

it's really late and i don't have an example for you right now, but i'll post one tomorrow.

but i have seen it done...

Dru Lee Parsec
10-28-2002, 12:07 PM
Sorry Inkedmn, I didn't log onto my computer all weekend long so I didn't see your question.

As you discovered, yes, you can put multiple listeners on a component