Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在按钮单击侦听器中使用 replaceComponent(oldButton, newTextField) ,之后该操作按钮被文本字段替换,但我必须单击它才能输入文本。
我想单击按钮并将文本写入文本字段而不单击文本字段。我怎样才能做到这一点?
您需要使用AbstractField#focus()方法请求关注新的 TextField ,即
replaceComponent(oldButton, newTextfield) newTextField.focus();