so I have a couple JButtons
, and hundreds of JTextFields
throughout a program (with CardLayout
, don't worry). I want these JButtons
to find the JTextField
that was last in focus, so when the button is clicked, it sets the text of that field to be whatever that button is.
I have tried getFocusOwner()
and getMostRecentFocusOwner()
on JTextFields
that were setFocusable(true)
I'm hoping there's a method already available somewhere for this.