views:

36

answers:

2
saveButton.setStylePrimaryName("jtyfj");

If I do that to a button, it removes the default "gwt-button' class and replaces it with 'jtyfj'. My question is, is there a way to apply this yo all buttons by default. I'd really rather not have any default gwt-styles being referenced.

Also, is there a way to do it with a ClientBundle CSSResource?

+4  A: 

Why don't you just use another class that extends Button and set the style in the constructor?

public class StyleButton extends Button {  
     public StyleButton() {  
        this.setStylePrimaryName("jtyfj");  
      }  
} 

Whenever you create an instance of StyleButton it will have the style you want.

Chris Boesing
So simple! Thanks. :DNow how would I use it with my client bundle css? Trouble is, the class names are obfuscated.
Matt H
this.setStylePrimaryName(Resources.INSTANCE.style().button());That's how. Thanks again.
Matt H
A: 

I you want the style to be applied to ALL the buttons in your app. You may as well customize the GWT Standard Theme css and replace the desired style with your own:

  .gwt-Button {
  /* Replace the following properties with your own */
  margin: 0;
  padding: 3px 5px;
  text-decoration: none;
  font-size: small;
  cursor: pointer;
  cursor: hand;
  background: url("images/hborder.png") repeat-x 0px -27px;
  border: 1px outset #ccc;
}

It will avoid creating a new control for each widget you want to customize.

DrDro