Matthew H
Matthew H

Reputation: 5879

GWT setStylePrimaryName for all of instances of a widget

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?

Upvotes: 0

Views: 962

Answers (2)

Jla
Jla

Reputation: 11374

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.

Upvotes: 0

Chris Boesing
Chris Boesing

Reputation: 5279

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.

Upvotes: 4

Related Questions