Hi,
I am not sure which way to go in terms of researching how to solve my little issue. I have a few JTextFields where I want to take different action depending on which they click on (or move to with the keyboard). Whichever they choose will determine which options are available to the user.
I know I could duplicate code and use both a KeyListener and a MouseListener, but I think there must be a better way.
Thanks for the help
BD
Edit: I'd also like to know which JTextField is the one they selected. Would this be handled by the setActionCommand() or is there some way to test for focus?
Edit #2: I am reading about FocusListeners. Is it better to have the class implement FocusListener or create a new instance for each JTextField I want to watch?
Edit #3: Let me apologize for wasting your time. I was too quick to post this question, and have subsequently found my own answer. I'll try to resist the urge in the future until I am sure I can't find my own answer. :-)
I am not sure which way to go in terms of researching how to solve my little issue. I have a few JTextFields where I want to take different action depending on which they click on (or move to with the keyboard). Whichever they choose will determine which options are available to the user.
I know I could duplicate code and use both a KeyListener and a MouseListener, but I think there must be a better way.
Thanks for the help
BD
Edit: I'd also like to know which JTextField is the one they selected. Would this be handled by the setActionCommand() or is there some way to test for focus?
Edit #2: I am reading about FocusListeners. Is it better to have the class implement FocusListener or create a new instance for each JTextField I want to watch?
Edit #3: Let me apologize for wasting your time. I was too quick to post this question, and have subsequently found my own answer. I'll try to resist the urge in the future until I am sure I can't find my own answer. :-)