# How to resize the DialogWindow to fit the content component?

**URL:** <https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905>\
**Category:** General JUCE discussion\
**Created:** [June 22, 2006, 4:37am UTC](https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905 "2006-06-22T04:37:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ring2](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@ring2](https://forum.juce.com/u/ring2)\
**Post date:** [June 22, 2006, 4:37am UTC](https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905/1 "2006-06-22T04:37:09Z")

</div>

Hi there,

I’m now writing a dialog. I’d like to know how to get the height of title bar and thickness of dialog’s border to fit the dialog size to content component.

I could use DocumentWindow::getBorderThickness() but I found ResizableWindow::resizeToFitContent() and DocumentWindow::getTitleBarHeight() are private.

Are there any way to get the height of the title bar in the DialogWindow? Or are there any way to resize the DialogWindow to fit the content component?

Best regards,  
Masanao Hayashi

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 22, 2006, 8:15am UTC](https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905/2 "2006-06-22T08:15:34Z")

</div>

It’s much easier than that - the ResizableWindow::setContentComponent() method has a “resizeToFit” parameter, which you can set to true.

---

<div class="post-metadata">

**Author:** ![ring2](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@ring2](https://forum.juce.com/u/ring2)\
**Post date:** [June 22, 2006, 5:05pm UTC](https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905/3 "2006-06-22T17:05:04Z")

</div>

Thanks. It works! Now I’m doing as follows.

`	setOpaque(true);
	setVisible(true);
	setResizable(false, false);
	setTitleBarHeight(22);
	setContentComponent(new CMainPane, true, true);
	centreWithSize(getWidth(), getHeight());`

Masa

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [May 12, 2017, 10:01am UTC](https://forum.juce.com/t/how-to-resize-the-dialogwindow-to-fit-the-content-component/905/4 "2017-05-12T10:01:31Z")

</div>

Closed on May 12, 2017, 10:01am UTC


