Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8052477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T07:33:18+00:00 2026-06-05T07:33:18+00:00

I want to change the color of a g:label using java code on a

  • 0

I want to change the color of a g:label using java code on a onBlur event.
I am using eclipse, UIBinder.

This is what I have in mind although it doesn’t work.

In my StandardDocumentDownload.ui.xml file

<ui:style>     
   .testStyle {
   }
   .styleRequiredData
   {
        color:red;

    }
 </ui:style>

this is the event in my standardDocumentDownload.java file

@UiHandler("comboTitle")
void onComboTitleBlur(BlurEvent event) {
    int title = comboTitle.getSelectedIndex();

    if(title == 0)
    {
        labTitleReq.setText("Please enter a value");
        labTitle.addStyleName("styleRequiredData");
    }
    else
    {
        labTitleReq.setText("");
    }

}

How could I add the color red to the existing style of the label upon the firing of the event.

Kind regards

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T07:33:19+00:00Added an answer on June 5, 2026 at 7:33 am

    See here under Programmatic access to inline Styles

    for you, it shoulbe be something like :

    <ui:style type="com.yourapp.YourClass.MyStyle">     
        .testStyle {
        }
        .styleRequiredData
        {
            color:red;
        }
    </ui:style>
    
    public class YourClass extends Widget {
        interface MyStyle extends CssResource {
            String testStyle();
            String styleRequiredData();
        }
    
        @UiField MyStyle style;
    
        /* ... */
    
        @UiHandler("comboTitle")
        void onComboTitleBlur(BlurEvent event) {
            int title = comboTitle.getSelectedIndex();
            if(title == 0){
                labTitleReq.setText("Please enter a value");
                labTitle.getElement().addClassName(style.styleRequiredData);
            } else {
                labTitleReq.setText("");
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to change color of h3 links to red in this code: <div
I want to change the background color of my label with a variable how
Issue In the below code , say if i want to change the color
I want to change color of label which is in usercontrol. as it in
I have a label containing some text and I want to highlight or change
I have added a label to the jquery ui progressbar using this demo .
I want to change the color of label text on selection and get back
I want to change background color of the row in particular condition.My code is
In my example below I have several objects. I want to change the label
I have a layout like this in which I want to display a label

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.