MayoMan
MayoMan

Reputation: 4917

Creating my own GWT Button CSS stylr

I want to set a custom background for all my Buttons in my GWT app. I'm using the standard GWT Button class. So ( As recommended by one of the guys in SO ) in my CSS file I have

.gwt-Button
{
background-color: red;
}

However this does not get applied to my Button. Then I tried

myButton.setStyleName("gwt-Button");

Same result. I then changed the name of the style to "gwt.Button1" , set this as my style name and hey presto it works. So investigating why I couldn't modify the inbuilt CSS style I noticed that when I compiled my GWT project ( I'm using Eclipse ) that in my WAR folder there is a folder created called war/myModule/gwt/standard and in this folder are CSS files which contain the default GWT styles. ( At least that's my take on it ) So my question is how do I apply my own styling to gwt-Button and why are these css files being put in this folder and can I change these?

Upvotes: 1

Views: 207

Answers (2)

Abhijith Nagaraja
Abhijith Nagaraja

Reputation: 3380

I think the below link should solve your problem

GWT theme style overrides my css style

If not revert back. Cheers :)

Upvotes: 2

Suresh Atta
Suresh Atta

Reputation: 121998

Project --->
|
Src
|
package com.xxxxx
|
|
folder(resources(any))
|
|
css(folder)
|
|
YourcssFile.css(write your css here )

Refer :https://developers.google.com/web-toolkit/doc/latest/DevGuideUiCss#cssfiles

And in GWT.xml file

<stylesheet src='css/YourcssFile.css' />

Upvotes: 1

Related Questions