# Shouldn't AlertWindow inherit L&F from associated component?

**URL:** <https://forum.juce.com/t/shouldnt-alertwindow-inherit-l-f-from-associated-component/55388>\
**Category:** General JUCE discussion\
**Created:** [March 15, 2023, 6:32pm UTC](https://forum.juce.com/t/shouldnt-alertwindow-inherit-l-f-from-associated-component/55388 "2023-03-15T18:32:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fberti](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@fberti](https://forum.juce.com/u/fberti)\
**Post date:** [March 15, 2023, 6:32pm UTC](https://forum.juce.com/t/shouldnt-alertwindow-inherit-l-f-from-associated-component/55388/1 "2023-03-15T18:32:06Z")

</div>

Hello devs,

I’m facing an issue with the AlertWindow look and feel, I thought it was supposed to use the associated component look and feel when being painted but it doesn’t seem to be the case.

By looking at the AlertWindow paint() method I see:

```auto
//==============================================================================
void AlertWindow::paint (Graphics& g)
{
    auto& lf = getLookAndFeel();
    lf.drawAlertBox (g, *this, textArea, textLayout);

    g.setColour (findColour (textColourId));
    g.setFont (lf.getAlertWindowFont());
    ...
}

```

So it doesn’t seem to be the case.  
How am I supposed to apply a specific LookAndFeel to an AlertWindow when launching it with the dedicated static methods, like juce::AlertWindow::showMessageBoxAsync?

I know I should normally use the global LookAndFeel, but this is a very specific situation where I need a different one, so the global solution is not viable for me.

Any ideas?  
Federico Berti

---

<div class="post-metadata">

**Author:** ![fberti](https://avatars.discourse-cdn.com/v4/letter/f/5f8ce5/32.png) [@fberti](https://forum.juce.com/u/fberti)\
**Post date:** [March 15, 2023, 6:58pm UTC](https://forum.juce.com/t/shouldnt-alertwindow-inherit-l-f-from-associated-component/55388/2 "2023-03-15T18:58:53Z")

</div>

After some more research I’ve been able to address it by overriding the createAlertWindow(…) method on my specific LookAndFeel class, like this:

```auto
AlertWindow* ActivationComponentsLookAndFeel::createAlertWindow(const String& title, const String& message,
	const String& button1,
	const String& button2,
	const String& button3,
	MessageBoxIconType iconType,
	int numButtons, Component* associatedComponent)
{
	juce::AlertWindow* alert = juce::LookAndFeel_V4::createAlertWindow(title, message, button1, button2, button3, iconType, numButtons, associatedComponent);
	alert->setLookAndFeel(this);

	return alert;
}

```

It works, but I’m not sure it’s the best solution.
