In fact, the solution is simpler than I had thought. It is sufficient to keep a reference to the object of which you want to change the css class, then invoke again the method setStyleName. Keep a reference to the widget (in our case productInfo) as a field of the original class, then change the css assignment when necessary.
So in the end the object productInfo becomes a field in the main class and then we can change the css assignment simply by invoking again the method setStyleName passing the new css class.
The object productInfo becomes a field in the main class
protected HTMLFlow productInfo = new HTMLFlow();
The code of the question example is modified as in the snippet
productInfo.setContents(productInfoHtml);
productInfo.setStyleName("login-product-info");
productInfo.setHeight(16);
productInfo.setWidth100();
Now I can change the css class assigned to the widget productInfo when the event onMouseOver occurs on the object forgot.
forgot.addMouseOverHandler(new MouseOverHandler() {
@Override
public void onMouseOver(MouseOverEvent event) {
productInfo.setStyleName("my-new-style");
}
});