Getting the window caption

I create a new window with a caption. I then add a composite to the window using setContent. How do I get the caption of the window where the composite exists?

I have tried calling getWindow() from within the composite and it throws a null pointer exception. Does it matter that I am adding the window from inside an event method?

Thanks! Under the gun here …

Hi,

The getWindow() returns null until the window object has been attached to the application object, so you can’t call it from the constructor of the composite. See
attach()
in Component for explanation and instructions for solving the problem in attach() method. You can solve the problem in other ways as well, such as passing a reference to the Window object as a parameter for the constructor.

The issue is described with a solution in the Knowledge Base article
#71: The getParent()/getWindow()/getApplication() returns null
(Pro Account required).

Also the section
Accessing Session-Global Data
in the Book deals with the problem with getApplication().