AlertWindow Look & Feel Bug?



My app is needlessly complicated; it is basically a large tumor on an app written by a third party. There is something wrong with the the third-party app’s look & feel such that you cannot create their components unless their look & feel is set as the default. (You get exceptions in something to do with looking up Colours.) But I need components of my app to have different look & feel than theirs, so I’ve managed to create my own look & feel and to have my components use it while theirs uses theirs.

(Side question: I don’t really understand why what I’m doing works. I set their look & feel as the default and create their component in a tab of my main component. Then I create my own look & feel and apply it to the main window. This changes the look & feel for the main window and my main component (its child), but not for their component. Is their component blocked from inheriting the new look & feel by the fact that it has been explicitly set?)

At one point in my component, I need to create an AlertWindow, which I do using the static AlertWindow::showOkCancelBox() method, setting the associatedComponent to this. Problem: The alert that pops up appears to be using the default look & feel (theirs). I tried stepping to see what was up; at least to a first pass the AlertWindow seemed to be referencing my look & feel, but there were a lot of nested calls, and at least one naked getLookAndFeel() unassociated with any component (which would get the default, right?). Is this a bug? Or if I’m doing something wrong, can someone assist me?



The Component::getLookAndFeel call actually looks up the component hierarchy to see if a l+f was explicitly set for one of its parents, and returns that. That means that any embedded components inherit their parent’s l+f. The default one is used as a last resort if it can’t find an explicitly set one.


Okay, so, then, I’m doing something wrong? Any ideas on what?

Is there something else I need to do to set the look & feel of the AlertWindow? I tried creating a local AlertWindow and setting its look & feel directly before calling the showOKCancelBox method on it. I still got the wrong look & feel.

Anybody want to address my side question?



The AlertWindow will pick up its l+f from the associatedComponent parameter that most of the static methods take.


I guess something’s well and truly broken in my (or the third-party) code, then. (As I’m setting the associatedComponent to ‘this’, where ‘this’ is the MainComponent which is using the proper look & feel, and yet I’m getting the other look & feel.)

Luckily it’s just the AlertWindow that’s not behaving; it’s a small enough problem that I can probably get away with just leaving it broken. Still wish I understood why some components inherit look & feel and others don’t, though.