PDA

View Full Version : WindowManager window id



lightblade
23 Oct 2008, 12:50 AM
It says windows are automatically registered with WindowManager when it is created. WindowManager retrieve the window by id, but how do I know what is the id of the window? There's not method under Window that let me get it's id.

takayser
23 Oct 2008, 10:22 PM
there is:

Window w = new Window();
w.getId();(id is inherited from Component)

lightblade
24 Oct 2008, 1:23 AM
Nope, that doesn't work. Try this line:

System.out.println(WindowManager.get().get(new Window().getId()));

I got a null;

takayser
24 Oct 2008, 2:24 AM
if you call window.show(), then the Window will be registered by the WindowManager (maybe also by calling other methods)
Try this:

Window w = new Window();
System.out.println(w.getId());
w.show();
Window w2 = WindowManager.get().get(w.getId());
System.out.println(w2.getId());