# How to create a window with custom title bar?

**URL:** <https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469>\
**Category:** General JUCE discussion\
**Created:** [October 24, 2023, 3:48pm UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469 "2023-10-24T15:48:45Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [October 24, 2023, 3:48pm UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469/1 "2023-10-24T15:48:45Z")

</div>

Is there a way to create my own custom title bar for a window? I want my window to look “light weight”, so that it doesn’t have OS’s own title bar, but something simpler created by myself.

The first thing that came to my mind was to just use juce::TopLevelWindow and turn off it’s title bar with setUsingNativeTitleBar(false). This obviously doesn’t let the user drag the window anymore. So to make the window draggable again, I read the mouse up/down/drag and set its own bounds so it can be dragged. This unfortunately created noticeable lag in dragging which isn’t present in regular windows, so it’s a no-go.

Is there some other obvious option I’ve missed which lets me design my own drag bar and get proper low lag for window dragging around the screen?

---

<div class="post-metadata">

**Author:** ![cpr2323](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/cpr2323/32/18682_2.png) [@cpr2323](https://forum.juce.com/u/cpr2323)\
**Post date:** [October 24, 2023, 4:22pm UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469/2 "2023-10-24T16:22:41Z")

</div>

I was going to suggest the solution you tried, but obviously it isn’t working for you. I can’t think of anything inherint to the process that would cause it, so I wonder if there is someting (a sort of event feedback loop?) that is slowing things down? like two pieces of code competing to set window position. maybe you could do some measuring to see where the time seems to be going?

---

<div class="post-metadata">

**Author:** ![stephenk](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/stephenk/32/15198_2.png) [@stephenk](https://forum.juce.com/u/stephenk)\
**Post date:** [October 24, 2023, 6:37pm UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469/3 "2023-10-24T18:37:30Z")

</div>

I think it will work if you use a DocumentWindow and set Native Title Bar to false. Then you will get the Juce Title Bar, and you can customize it with the LookAndFeel methods.

---

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [October 25, 2023, 9:14am UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469/4 "2023-10-25T09:14:04Z")

</div>

This is interesting:  
When I use the native title bar, there’s no lag.  
But when I don’t use the native title bar, there is lag by default in JUCE’s own implementation.

---

<div class="post-metadata">

**Author:** ![Kraku](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@Kraku](https://forum.juce.com/u/Kraku)\
**Post date:** [October 25, 2023, 9:39am UTC](https://forum.juce.com/t/how-to-create-a-window-with-custom-title-bar/58469/5 "2023-10-25T09:39:30Z")

</div>

I found a fix:

The lag appears when you have the following settings in effect:

- The window has been added to the desktop instead of having a parent Component.
- The window uses JUCE’s own title bar instead of native title bar.

So when I set “bool addToDesktop = false” in the window’s constructor and use parentComponent-\>addAndMakeVisible(windowComponent), the lag disappears.
