/** Try to register the listener.
*/
private boolean registerListeners ()
{
// Get toolkit.
XExtendedToolkit xToolkit = getToolkit ();
// Register at toolkit as focus event listener.
if (xToolkit != null)
{
xToolkit.addTopWindowListener (mxListener);
int nTopWindowCount = xToolkit.getTopWindowCount();
try
{
com.sun.star.lang.EventObject aEvent = new com.sun.star.lang.EventObject();
for (int i=0; i<nTopWindowCount; i++)
{
XAccessible xAccessible = (XAccessible) UnoRuntime.queryInterface(
XAccessible.class,
xToolkit.getTopWindow(i));
XAccessibleContext xContext = xAccessible.getAccessibleContext();
if (xContext.getAccessibleName().length() > 0)
{
// Simulate an event that leads to registration the
// listener at the window.
aEvent.Source = xToolkit.getTopWindow(i);
mxListener.windowOpened (aEvent);
}
}
}