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 6348423
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T21:24:57+00:00 2026-05-24T21:24:57+00:00

I want to add a TextField with an integrated hint text, a user prompt,

  • 0

I want to add a TextField with an integrated hint text, a user prompt, a placeholder until the user enters text. The prompt text 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() {

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

        }
    };

    public M2MHintTextField(final String hint)    {
        super(hint);
        this.hint = hint;
        super.addListener(this.listener);
    }

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

    }
}
  • 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-05-24T21:24:58+00:00Added an answer on May 24, 2026 at 9:24 pm

    Built-in feature

    After some research I found that this is an integrated feature in all of the input controls (TextField, TextArea, DateField, ComboBox).

    Vaadin Flow (Vaadin 10)

    The feature is a property called Placeholder.

    You can optionally pass the placeholder text to the constructor of TextField, along with optional initial value.

    new TextField( "label goes here" , "hint goes here" ) 
    

    Or call the setter and getter: TextField::setPlaceholder and TextField.getPlaceholder.

    myTextField.setPlaceholder( "Hint goes here" ) ;
    

    Vaadin 8

    The feature is a property called Placeholder.

    Call the getter/setter methods: TextField::getPlaceholder and TextField.setPlaceholder.

    myTextField.setPlaceholder( "Hint goes here" ) ;
    

    Vaadin 7

    The feature is a property called InputPrompt.

    Call the getter/setter methods: TextField::setInputPrompt and TextField::getInputPrompt.

    myTextField.setInputPrompt("Hint goes here"); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hey guys, I'm trying to add a textfield.text entry to an array. I want
i want to add textfield on tableview each and access the textfield's text by
I want to add and fetch the value from dynamically created textfield with tag
i want to ask. How to add break after paragraph in one text field
I want to add time in my textfield and for that as per client's
I want to add a variable place holder in my textField and when something
I want to add a simple piece of text to the stage and add
I want To add textfield dynamically with tag so that it can give unique
I want To add textfield dynamically with tag so that it can give unique
I want to add a textfield dynamically with tag so that it can give

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.