# setContentComponent is deprecated. What should I do?

**URL:** <https://forum.juce.com/t/setcontentcomponent-is-deprecated-what-should-i-do/24330>\
**Category:** General JUCE discussion\
**Created:** [September 22, 2017, 4:43pm UTC](https://forum.juce.com/t/setcontentcomponent-is-deprecated-what-should-i-do/24330 "2017-09-22T16:43:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [September 22, 2017, 4:43pm UTC](https://forum.juce.com/t/setcontentcomponent-is-deprecated-what-should-i-do/24330/1 "2017-09-22T16:43:14Z")

</div>

…Hi, what should I do to add a content component to a newly created window?  
I’ve got a window but I can’t add a normal component, what is the best way to do that?  
Thanks,  
Dave.

```
class DeviceWindow : public DocumentWindow
{
public:
	DeviceWindow(const String& name, Colour backgroundColour, int buttonsNeeded, AudioDeviceManager &manager)
		: DocumentWindow(name, backgroundColour, buttonsNeeded)
	{

The following is illegal, because my windows has no content component:
// addAndMakeVisible(audioSetupComp = new AudioDeviceSelectorComponent(manager, 0, 256, 0, 256, true, true, true, false));

	}

	void closeButtonPressed()
	{
		delete this;
	}

private:
	ScopedPointer<AudioDeviceSelectorComponent> audioSetupComp;
	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DeviceWindow)
};
```

---

<div class="post-metadata">

**Author:** ![DaveH](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daveh/32/4924_2.png) [@DaveH](https://forum.juce.com/u/DaveH)\
**Post date:** [September 22, 2017, 6:23pm UTC](https://forum.juce.com/t/setcontentcomponent-is-deprecated-what-should-i-do/24330/2 "2017-09-22T18:23:32Z")

</div>

OK, I’ve copied the way Main.cpp and MainComponent works and I got this-  
It seems to work OK. Although I suspect there’s a better way to grab the device manager other than passing it down to my window component.

```
Component *makeDeviceContent(AudioDeviceManager &);

class DeviceWindow	: public DocumentWindow
{
public:
	DeviceWindow(const String& name, Colour backgroundColour, int buttonsNeeded, AudioDeviceManager &manager)
		: DocumentWindow(name, backgroundColour, buttonsNeeded)
	{
		setContentOwned(makeDeviceContent(manager), true);
	}

	void closeButtonPressed()
	{
		delete this;				    
	}

private:

	JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DeviceWindow)
};
```
