# Jucer delete the default constructor

**URL:** <https://forum.juce.com/t/jucer-delete-the-default-constructor/2091>\
**Category:** Windows\
**Created:** [September 14, 2007, 9:37am UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091 "2007-09-14T09:37:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 14, 2007, 9:37am UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/1 "2007-09-14T09:37:26Z")

</div>

How I can save default constructor

`MainWindow :: MainWindow()
: DocumentWindow (T("Hello World"),
				  Colours::lightgrey, 
				  DocumentWindow::allButtons, 
				  true)`  
when I work with Jucer?  
Jucer deleted

`: DocumentWindow (T("Hello World"),
				  Colours::lightgrey, 
				  DocumentWindow::allButtons, 
				  true)`  
when I save file! 😢

---

<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:** [September 14, 2007, 9:54am UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/2 "2007-09-14T09:54:50Z")

</div>

Put it in the “member initialisers” field in the jucer class info page.

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 14, 2007, 11:11am UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/3 "2007-09-14T11:11:11Z")

</div>

Jucer add metod

```auto
addAndMakeVisible (mb_play = new TextButton (T("new button")));
```

but it results in a mistake. I add manually

```auto
Component::addAndMakeVisible (mb_play = new TextButton (T("new button")));
```

Jucer deleted

```auto
Component::
```

and I need add it again…  
What I can make to not repeat add it again?

---

<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:** [September 14, 2007, 12:28pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/4 "2007-09-14T12:28:50Z")

</div>

You can’t edit that bit - it’s generated by the jucer. Looks like it should work fine to me - why’s it giving an error?

---

<div class="post-metadata">

**Author:** ![kunitoki](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/kunitoki/32/15_2.png) [@kunitoki](https://forum.juce.com/u/kunitoki)\
**Post date:** [September 14, 2007, 2:16pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/5 "2007-09-14T14:16:51Z")

</div>

if you look at the header file generated, it states:

`Be careful when adding custom code to these files, as only the code within
  the "//[xyz]" and "//[/xyz]" sections will be retained when the file is loaded
  and re-saved.`

so add your own code only inside those [xyz] sections and not outside them !

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 17, 2007, 2:31pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/6 "2007-09-17T14:31:22Z")

</div>

I add new button in DocumentWindow. Jucer add the button with addAndMakeVisible metod? and when my programm is running I receive:  
“juce\_application.exe has triggered a breakpoint” and stop in

```auto
void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)
{
    /* Agh! You shouldn't add components directly to a ResizableWindow - this class
       manages its child components automatically, and if you add your own it'll cause
       trouble. Instead, use setContentComponent() to give it a component which
       will be automatically resized and kept in the right place - then you can add
       subcomponents to the content comp. See the notes for the ResizableWindow class
       for more info.

       If you really know what you're doing and want to avoid this assertion, just call
       Component::addAndMakeVisible directly.
   */
    jassertfalse //my programm is stopped

    Component::addAndMakeVisible (child, zOrder);
}
```

And I have to replaced addAndMakeVisible to Component::addAndMakeVisible…

When I use setContentComponent I have problem “Unhandled exception at 0x0051dd26 in juce\_application.exe: 0xC0000005: Access violation reading location 0x0000001c.” in file “\src\juce\_appframework\gui\graphics\geometry\juce\_rectangle.h”

```auto
    /** Returns the width of the rectangle. */
    inline int getWidth() const throw() { return w; }
```

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 17, 2007, 2:33pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/7 "2007-09-17T14:33:27Z")

</div>

I add new button in DocumentWindow. Jucer add the button with addAndMakeVisible metod? and when my programm is running I receive:  
“juce\_application.exe has triggered a breakpoint” and stop in

```auto
void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)
{
    /* Agh! You shouldn't add components directly to a ResizableWindow - this class
       manages its child components automatically, and if you add your own it'll cause
       trouble. Instead, use setContentComponent() to give it a component which
       will be automatically resized and kept in the right place - then you can add
       subcomponents to the content comp. See the notes for the ResizableWindow class
       for more info.

       If you really know what you're doing and want to avoid this assertion, just call
       Component::addAndMakeVisible directly.
   */
    jassertfalse //my programm is stopped

    Component::addAndMakeVisible (child, zOrder);
}
```

And I have to replaced addAndMakeVisible to Component::addAndMakeVisible…

When I use setContentComponent I have problem “Unhandled exception at 0x0051dd26 in juce\_application.exe: 0xC0000005: Access violation reading location 0x0000001c.” in file “\src\juce\_appframework\gui\graphics\geometry\juce\_rectangle.h”

```auto
    /** Returns the width of the rectangle. */
    inline int getWidth() const throw() { return w; }
```

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 17, 2007, 2:34pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/8 "2007-09-17T14:34:59Z")

</div>

I add new button in DocumentWindow. Jucer add the button with addAndMakeVisible metod? and when my programm is running I receive:  
“juce\_application.exe has triggered a breakpoint” and stop in

```auto
void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)
{
    /* Agh! You shouldn't add components directly to a ResizableWindow - this class
       manages its child components automatically, and if you add your own it'll cause
       trouble. Instead, use setContentComponent() to give it a component which
       will be automatically resized and kept in the right place - then you can add
       subcomponents to the content comp. See the notes for the ResizableWindow class
       for more info.

       If you really know what you're doing and want to avoid this assertion, just call
       Component::addAndMakeVisible directly.
   */
    jassertfalse //my programm is stopped

    Component::addAndMakeVisible (child, zOrder);
}
```

And I have to replaced addAndMakeVisible to Component::addAndMakeVisible…

When I use setContentComponent I have problem “Unhandled exception at 0x0051dd26 in juce\_application.exe: 0xC0000005: Access violation reading location 0x0000001c.” in file “\src\juce\_appframework\gui\graphics\geometry\juce\_rectangle.h”

```auto
    /** Returns the width of the rectangle. */
    inline int getWidth() const throw() { return w; }
```

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 17, 2007, 2:34pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/9 "2007-09-17T14:34:59Z")

</div>

I add new button in DocumentWindow. Jucer add the button with addAndMakeVisible metod? and when my programm is running I receive:  
“juce\_application.exe has triggered a breakpoint” and stop in

```auto
void ResizableWindow::addAndMakeVisible (Component* const child, int zOrder)
{
    /* Agh! You shouldn't add components directly to a ResizableWindow - this class
       manages its child components automatically, and if you add your own it'll cause
       trouble. Instead, use setContentComponent() to give it a component which
       will be automatically resized and kept in the right place - then you can add
       subcomponents to the content comp. See the notes for the ResizableWindow class
       for more info.

       If you really know what you're doing and want to avoid this assertion, just call
       Component::addAndMakeVisible directly.
   */
    jassertfalse //my programm is stopped

    Component::addAndMakeVisible (child, zOrder);
}
```

And I have to replaced addAndMakeVisible to Component::addAndMakeVisible…

When I use setContentComponent I have problem “Unhandled exception at 0x0051dd26 in juce\_application.exe: 0xC0000005: Access violation reading location 0x0000001c.” in file “\src\juce\_appframework\gui\graphics\geometry\juce\_rectangle.h”

```auto
    /** Returns the width of the rectangle. */
    inline int getWidth() const throw() { return w; }
```

---

<div class="post-metadata">

**Author:** ![Denis](https://avatars.discourse-cdn.com/v4/letter/d/5e9695/32.png) [@Denis](https://forum.juce.com/u/Denis)\
**Post date:** [September 17, 2007, 2:42pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/10 "2007-09-17T14:42:52Z")

</div>

Sorry, it’s my browser…

---

<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:** [September 17, 2007, 2:58pm UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/11 "2007-09-17T14:58:27Z")

</div>

You shouldn’t design a DocumentWindow in the jucer - use the jucer to build a normal component, and add that to a DocumentWindow as its content component.

I did explain this pretty clearly in that comment, didn’t I?

---

<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:07am UTC](https://forum.juce.com/t/jucer-delete-the-default-constructor/2091/12 "2017-05-12T10:07:15Z")

</div>


