dcsimg

How do I get focus on a particular component on the screen. I tried requestFocus(), but it did not work. Do I have to do something special to be able to use requestFocus() method on a Button, or a TextField?

Simon Brown

The requestFocus() method will only work when the component is visible so ensure that your window/applet is visible and that your component has been added to it. Then call the requestFocus() method on the component to switch the focus.