Is it possible to change or draw over a component at runtime?

I have a dropdown menu and I want that when I change selection, the component drawn at another location is changed or drawn over.
The way I do this is by keeping a std::vector<Component*> object, then in the onchange eventlistener, I choose a different Component object from the vector of components get selected. I then call repaint in the onchange handler method itself.
However, this doesn’t work and the drawn component remains.

You don’t say how you implement changing to another Component exactly, but normally I’d just set the old Component as not visible and the new Component as visible.

That is exactly how I am trying to do it. I have a vector of pointers to the components (they inherit the same base class). Then in the changeSelection handler I pick one of the Components from the vector, after setting the current one isVisible(false)(picking here means assigning to a variable which is used in ‘resized’ function to setBounds of the component).

I’m just reaching here, but maybe there is something going on with the opacity of your components? Try filling the background of each of your components with the same color as your mainComponent in their paint() function, and setting them to setOpaque(true) - so that they completely cover the area.