Initial focused object in container?
Posted on 2005-04-19
I have the following code (scene and bankContainer are both Container subclasses)
bankContainer = new BankContainer();
inside the BankContainer constructor:
userID = new BankSingleLineEntry(0,0,200,30,16); // subclass of Component
userID.requestFocus(); // I want it to start focussed
However, that component wasn't starting with the focus. Using a debugger I found out it was because the requestFocus() call was failing because the bankContainer had no peer - the bankContainer is added to the scene *after* the BankContainer() constructor and requestFocus are called.
What's the right way to go about setting the initally focused object in a container?