Creating a TextField with integrated hint text

Hello Forum!

I’m new to Vaadin and am trying to get used to the framework.

I have a query though. I want to add a TextField with an integrated hint text that disappears when the TextField is focused and re-appears if the TextField loses focus and no text is entered. I initially thought that this would be a generic feature for Vaadin TextFields but that doesn’t seem to be the case.

Now I’m looking for a way to implement my own extension of the TextField to add this feature. But I’m stuck…

My question is if anyone here has done this before or instinctively know how it should be done?

This is how far I’ve come:

package com.smarttrust.m2m.gui.admin;

import com.vaadin.event.FieldEvents.FocusEvent;
import com.vaadin.event.FieldEvents.FocusListener;
import com.vaadin.terminal.gwt.client.ui.VCalendarPanel.FocusChangeListener;
import com.vaadin.ui.TextField;

public class M2MHintTextField extends TextField implements FocusListener	{

	private final String hint;
	FocusListener listener = new FocusListener() {
		public void focus(FocusEvent event) {
			// TODO Auto-generated method stub
	public M2MHintTextField(final String hint)	{
		this.hint = hint;

	public void focus(FocusEvent event) {
		// TODO Auto-generated method stub

This is an integrated feature in all of the input controls (TextField, TextArea, DateField, ComboBox). It’s called “input prompt”, no need to create it again.


Ohh… Well, that’s embarrassing…
Maybe I should have added that I’m new to all types of Java UI-implementation… =)

Thank you!

No stress, glad I could help. Finding things isn’t always that easy, especially if the thing is named differently from what you’re used to.

And welcome to the forum! :slight_smile: