This week's book giveaway is in the Agile and other Processes forum. We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line! See this thread for details.
I am trying to use KeyListener on multiple TextFields in one applet. How do I ensure that the applet knows which one generated the event and modifies the other TextFields accordingly?
Paul Caudle
Ranch Hand
Joined: Jun 08, 2000
Posts: 64
posted
0
Hi Bryan, I hope this is the type of answer you're looking for here: the KeyEvent class inherits a method called getSource() which will return the object that dispatched the event in the first place. What you could do would be something like: if(keyEventObject.getSource() == TextFieldObject){ Do whatever you want if the source was that textField; } This will work well if you're handling your event in the same class that you declared your TextFields, which is usually what one would do. Hope that helps, Bryan, -Paul
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to
run our stuff on 16 servers instead of 3.