How to focus on a textfield when a dialog is opened?
I have a "ConnectServerDialog" which contains a "textfield", I want the textfield to be focused when the dialog is shown.
class ConnectServerDialog extends DialogWrapper { }
I tried to invoke:
textfield.requestFocus()
or
textfield.requetFoucsInWinows()
But neither works.
What's the correct solution?
请先登录再写评论。
Override com.intellij.openapi.ui.DialogWrapper#getPreferredFocusedComponent and return the component to be initially focused there.
That works! Thank you so much