Button addStyleName / removeStyleName problem

Hi,

I want to make a Link type button bolder when the user clicks to that button and make the rest of the Link Type buttons normal. I am using this code below.



public void buttonClick(ClickEvent event) {
		
	Button source = event.getButton();
		
	btnA.removeStyleName("menuLinkButtonClicked");
	btnB.removeStyleName("menuLinkButtonClicked");
	btnC.removeStyleName("menuLinkButtonClicked");
	btnD.removeStyleName("menuLinkButtonClicked");
	btnE.removeStyleName("menuLinkButtonClicked");
	btnF.removeStyleName("menuLinkButtonClicked");
		
	if (source == btnA ) {
		btnA.addStyleName("menuLinkButtonClicked");
		((MainWindow) getWindow()).showAnnouncementsView();
        } else if (source == btnB ) {
        	btnB.addStyleName("menuLinkButtonClicked");
            ((MainWindow) getWindow()).showPersonalInfoView();
        } else if (source == btnC ) {
        	btnB.addStyleName("menuLinkButtonClicked");
        	((MainWindow) getWindow()).showAcademicInfoView();
        } else if (source == btnD ) {
        	btnD.addStyleName("menuLinkButtonClicked");
        	((MainWindow) getWindow()).showMessagesView();
        } else if (source == btnE ) {
        	btnE.addStyleName("menuLinkButtonClicked");
        	((MainWindow) getWindow()).showMyAcademicInfoView();
        } else if (source == btnF ) {
        	btnF.addStyleName("menuLinkButtonClicked");
        	((MainWindow) getWindow()).showCourseRegistrationView();
        }
}


I am not getting the styles that i desire. Is there something i am missing?

Thanks
Regards

Seeing the related CSS would help. I’m guessing there’s a problem with the specificity of your selectors.

Hi Jouni,

As you suggested, with the help of Firebug and looking at the CSS hiearchy, I found out what i was doing wrong.
I fixed the problem by adding a style like


.menuLinkButtonClicked .v-button-caption {
  font-weight: bold;
}

Now it is working perfectly,
Thanks again for the reply