# How to create a dialog window

**URL:** <https://forum.juce.com/t/how-to-create-a-dialog-window/60501>\
**Category:** General JUCE discussion\
**Created:** [March 18, 2024, 11:07pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501 "2024-03-18T23:07:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 18, 2024, 11:07pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501/1 "2024-03-18T23:07:32Z")

</div>

Hello,  
I want to open a dialog window from the main window when I click some buttons or select items in combox etc  
That dialog window should contain buttons, sliders, comboboxes etc inside as child

DocumentWindow does not like to contain buttons, texteditors etc as childs  
Also, simple Component does not have background window (it is transparent)

So, how to create and open a modal or modeless dialog window in JUCE API?

Thanks

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [March 18, 2024, 11:11pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501/2 "2024-03-18T23:11:57Z")

</div>

> [@morphism](#):
>
> DocumentWindow does not like to contain buttons, texteditors etc as childs

You need to first put those children into a plain Component and then use that as the content component for the window.

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 18, 2024, 11:44pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501/3 "2024-03-18T23:44:00Z")

</div>

Hello, Xenakios

When I put that component (containing buttons etc) inside a DocumentWindow  
there is a altert message, which says don’t put child in the DocumentWindow (when debugging)

Could you please show me simple source code or web link about  
how to code what you are now saying (put those children into a plain Component and then use that as the content component for the window) ?

Thank you

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [March 18, 2024, 11:48pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501/4 "2024-03-18T23:48:09Z")

</div>

Don’t use addAndMakeVisible or similar to add the child component(s), you need to use setContentOwned or setContentNonOwned.

---

<div class="post-metadata">

**Author:** ![morphism](https://avatars.discourse-cdn.com/v4/letter/m/f9ae1b/32.png) [@morphism](https://forum.juce.com/u/morphism)\
**Post date:** [March 18, 2024, 11:54pm UTC](https://forum.juce.com/t/how-to-create-a-dialog-window/60501/5 "2024-03-18T23:54:54Z")

</div>

Hello,  
I understand now. I solved this issue  
I also find the link below

[Interacting with DocumentWindow from ContentComponent - General JUCE discussion - JUCE](https://forum.juce.com/t/interacting-with-documentwindow-from-contentcomponent/15286)

So thank you so much. I saved a lot of time by your help  
See you again
