2

I have a gwt application which I need to apply custom themes for specific widgets, so I can maintain the Standard gwt CSS (for other widgets that I don't need to apply css to) in the gwt.xml file :

<inherits name='com.google.gwt.user.theme.standard.Standard'/>

I am using ClientBundle and CssResource approach in my app. I have applied simple css however I need to make a css that will be able to apply css for: selected and not selected, hover and push events/actions on a widget, just like what the standard gwt css provides.

What to write in the my css file so that for a MenuBar when I apply this:

ManuBar menuBar = new MenuBar(false); 
menuBar.setStyleName(AppResources.INSTANCE.css().menuBar())

I will get the same MenuBar effects of a standard MenuBar css of gwt? With the App.css I have below, I just get a black menubar and the font-color of the menubar does not change, I think there is a proper way to apply css with gwt widgets, however I cannot find a good resource about this on the web. What I am trying to accomplish is to be able to change the menubar color theme to say, black, chrome or whatever color but still make the widget look like a real menubar.

App.css:

.menuBar {
    background:#3c3b37;
    font-weight:bold;
    color:#FFFFFF;
    font-size:10px;
}

2 Answers 2

3

I have a feeling you might be experiencing the problem lots of us face when we forget to call ensureInjected on the CssResource. The CSS never gets added to the page, and so it looks like it's not working.

AppResources.INSTANCE.css().ensureInjected();
Sign up to request clarification or add additional context in comments.

Comments

-1

why not try simply with menuBar.setStyleName("menuBar"); I'm sure this will work.

2 Comments

This won't work if the OP's using a ClientBundle for the CSS, because the CSS class name will be obfuscated by the generator.
@Ashok, perhaps you're right. I just used the plain old setStyleName with the same old CSS file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.