2

.class1{
  font-weight: bold;
  font-size:20px;
}

.class2{
  background: #ffffff;
  color: grey;
}

and GWT method

  private static final String STYLE2 = class2;
  private static final String STYLE1 = "class1";   
   
   
   
   HTML html = new HTML(htmlText);
    String text = html.getText();

    Label label = new Label();

    if (text.length() <= 50) {
      label.addStyleName(STYLE1);
    } else {
      text = text.substring(0, 500);
    }
    label.addStyleName(STYLE2);
    label.setText(text);
  }

what i want is when text become less than 50 apply both styles to label ... but it is overridden ... any help ??

1 Answer 1

4

you can use setStyleName with class name and boolean parameter as below:

label.setStyleName(STYLE2,true);

here true is boolean value to add/append css class name.

An alternate solution can be to concatenate and apply those styles.

lable.addClassName(STYLE1 +" "+STYLE2);
Sign up to request clarification or add additional context in comments.

Comments

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.