Search code examples
javagwtpopupui-design

How to apply a different backgroundcolor for GWT decoratedPopupPanel?


final DecoratedPopupPanel infoPopup = new DecoratedPopupPanel(true);
    infoPopup.setWidget(new Label("Table below displays the total number of users for each application for the selected time range."));
    infoPopup.setWidth("150px");

    inImage.addMouseOverHandler(new MouseOverHandler(){
        public void onMouseOver(MouseOverEvent arg0){
            int left = inImage.getAbsoluteLeft() + 10;
            int top = inImage.getAbsoluteTop() + 10;
           infoPopup.setPopupPosition(left, top);

            // Show the popup
            infoPopup.show();
        }

    });

    inImage.addMouseOutHandler(new MouseOutHandler(){
        public void onMouseOut(MouseOutEvent arg0){
           //hide
            infoPopup.hide();

        }
    });

Solution

  • You can achieve it by creating your own custom styling using CSS.

    By default DecoratedPopupPanel use gwt-DecoratedPopupPanel style defined in clean.css.

    .gwt-DecoratedPopupPanel .popupMiddleCenter {
        padding: 3px;
        background: #f1f1f1;
    }
    

    Create your own style and just update the background color property and apply the style on it as shown below:

    CSS:

    .myPopupPanelStyle {
      background: #0000FF;
    }
    

    JAVA:

    infoPopup.setStyleName("myPopupPanelStyle");