underline the letter in label, button-caption, accordion-item.

I’m using shortcut keys in my application. so i want to highlight the letter in label. some times first letter and sometimes second or third.
i am able to underline the first letter by using the “first-letter” in CSS but when i try “nth-letter()”, it is not working… is there any solution.

final Button btnEmployeeMaster = new NativeButton(“Employee”);



this is possible… and this is working… but i want to underline some letter in between otherthan firstletter…
just like
second letter is underlined… plz help…

Simple CSS won’t help you here. You need to add additional elements to the label, wrapping the letters you want to underline

new Label(“Employee”, ContentMode.HTML)

Thanks for reply, but i’m sorry to say that it is not working.
I wrote same as you wrote, then it was showing the quotes error…
then i tried to keep single quote near ‘underline’ then also not working.
then i tried tag also, but it was displaying what ever i have written in the quotes…
ContentMode.HTML is not at all working for this caption.
Label lab=new Label(“sssss”, ContentMode.HTML);
System.out.println(lab.getValue());//This one is printing as it is given in quotes along with HTML tags
Button button = new Button(lab.getValue());// Here also the same tags are displayed
button.addClickListener(new Button.ClickListener() {
public void buttonClick(ClickEvent event) {
layout.addComponent(new Label(“Thank you for clicking”));

Please Help.

ContentMode affects how the value of the Label is rendered, not how its caption is rendered. Thus, you probably need something like (untested)

Label l = new Label(null, ContentMode.HTML); // null caption so that it doesn't take space
l.setValue("html goes here");

java.lang.Error: Unresolved compilation problem: The constructor Label(String, ContentMode) is ambiguous

This is the error it showing if i write in that manner…

… new Label((String) null, …

Well, 8 month later, is there any vaadin integrated solution for this? I think assigning shortcuts to buttons or fields via Java code is just half of the solution. The assigned shortcut must be visible to the user too. And writing “ALT-N” behind the field label as shown in the book of vaadin (http://demo.vaadin.com/book-examples-vaadin7/book/#advanced.shortcut.focus) is…well…just for demo purpose. Every real user will laugh about this. Marking shortcut as underlined letter is quite common. Would be nice to get this in vaadin too.

Is there any solution?
Underline one letter in the button caption.


The link above your comment show clearly how to do it:

Button button = new Button("<u>Y</u>our Button");