piechos
piechos

Reputation: 123

Change widget appearance without using css

Is it possible to change widget appearance (border color) in GWT without using css file? I know that some components have methods like setBodyStyle(String style) which can be used instead of css files, but Widget class doesn't have this method.

EDIT: I'm rewriting a project and it was made like this:

public void changeActiveWidget(Widget newActiveWidget) {
        newActiveWidget.removeStyleName("inactive-area");
        newActiveWidget.addStyleName("active-area");
        if (activeWidget != null) {
            activeWidget.removeStyleName("active-area");
            activeWidget.addStyleName("inactive-area");
        }

        activeWidget = newActiveWidget;
    }

where inactive-area is gray border and active-area is red border which are defined in css file. Now I would like to do it without css file and I hae no idea how.

Upvotes: 0

Views: 66

Answers (1)

Jaroslav Záruba
Jaroslav Záruba

Reputation: 4876

This is very nasty (what you are describing sounds also wrong :) but you can access the widget's main element UIObject.html#getElement and from there you can change its properties, including style: Element.html#getStyle

public void changeActiveWidget(Widget newActiveWidget) { 
    newActiveWidget.getElement().getStyle().setBorderColor("WhiteSmoke");
}

Upvotes: 1

Related Questions