Estou com um problema no requestFocus(), não esta funcionando…
Na minha interface tem um JTextField e um JButton, quero que o foco fique no botao, pois configurei no JTextField uma mensagem q quando o usuario clicar apaga a mensagem…
Mas o foco ja começa nele… ai a mensagem nao aparece…
ja tentei…
myJBtton.requestFocus()… mas nao adiantou…
Então é preciso dar uma lida na API para ver o que pode ter acontecido
Talvez seu componente não seja displayable… De acordo com um trecho da API do metodo requestFocusInWindow:
[quote]public boolean requestFocusInWindow()
Requests that this Component get the input focus, if this Component’s top-level ancestor is already the focused Window. This component must be displayable, focusable, visible and all of its ancestors (with the exception of the top-level Window) must be visible for the request to be granted. Every effort will be made to honor the request; however, in some cases it may be impossible to do so. Developers must never assume that this Component is the focus owner until this Component receives a FOCUS_GAINED event.[/quote]
Estou tentando entender o que está acontecendo, mas dê uma pesquisada melhor nisso.