Tobias Krais wrote: > Hi together again, > > I have one more question. I would like to change the menus in a document > in the background. Up to now I can change menus for loaded documents in > the foreground. Here is the code: > -----%<----- > XPropertySet xps = (XPropertySet) > UnoRuntime.queryInterface(XPropertySet.class, > xDesktop.getCurrentFrame()); > > XLayoutManager xLayoutManager = (XLayoutManager) > UnoRuntime.queryInterface(XLayoutManager.class, > xps.getPropertyValue("LayoutManager")); > -----%<----- > > With this code (getCurrentFrame) I can only get the XLayoutManager of > the foreground Window. > > Background info: I wrote a java application that opens a document. > Shortly after loading the document I start changing the menus. It can > happen that meanwhile an other OO Document comes in foreground and I > change the menus of this foreground window. > > How can I get the XLayoutManager of the XComponent I am working on with > my application?
Stefan gave the right answer. I just wanted to add that relying on which window is in the foreground is a bad idea in general. It's platform dependent (on Linux it even depends on the particular window manager installed) and doesn't make your application reliable. Stefan's suggestion will work always. To express it in short terms: use "currentFrame" only if you are fine with getting which frame whatsoever or even no frame at all when OOo is still subject to focus changes caused by the WM. Ciao, Mathias -- Mathias Bauer - OpenOffice.org Application Framework Project Lead Please reply to the list only, [EMAIL PROTECTED] is a spam sink. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]