I am working on a simple java swing based application. How would I get and set the text of the currently focused textfield/textarea of a form?
I know how to determine
Yes:
Component focusOwner = ... if(focusOwner instanceof JTextComponent) { // a textfield or textarea is focused JTextComponent textComp = (JTextComponent) focusOwner; String s = textComp.getText(); }