File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark ""add" method" Watch ""add" method" New topic

"add" method

Candy Bortniker
Ranch Hand

Joined: Mar 17, 2003
Posts: 123
I have a program that is suppose to allow the user to press enter to move to the next textfield. My instructor says I need a "add" method that will put a listener into the vector. My problem is that I don't know really how to write this statement. There is a lot of code to this and I'm not sure how much you need to see to give me any help.
This is in LimitedTextContainer:

Here is the driver program:
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15302

If I understand what you are saying you will need something like...

Then calling this somewhere in your code would be

Without knowing what Listener needs added and to what Vector I took a guess at the Vector and made up a Listener name. I think the point your instructor is trying to make is code re-use. So instead of issuing the Vector's add() method whenever you need it, you would just call a single function that would do the same thing. However, this seems like calling an extra method because a Vector already has an add() method. So it kind of me.
[ March 01, 2004: Message edited by: Gregg Bolinger ]

GenRocket - Experts at Building Test Data
I agree. Here's the link:
subject: "add" method
It's not a secret anymore!