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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:17:05+00:00 2026-05-27T22:17:05+00:00

I took one custom text box image, in that text box I want to

  • 0

I took one custom text box image, in that text box I want to show “Enter password” and when I focus on to that text box field and enter any charectors it converts to asterisk symbols like password edit field.

I want like this below Image:

password Box

  • 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-27T22:17:05+00:00Added an answer on May 27, 2026 at 10:17 pm

    I think it is possible by only overriding paint(..) of the Editfield. May be following steps can achieve the desired behaviour:

    • Store original text to a local variable.
    • Generate fake text depending on focus status, original text etc.
    • Call super.paint(..), it will paint the field with fake text.
    • Use setText(..) to set original text back.

    Draft implementation:

    class MyEditField extends EditField {
        private final static String INIT_TEXT = "Enter Password";
    
        protected void paint(Graphics graphics) {
            String originalText = getText();
            String fakeText = originalText;
    
            if (originalText.equalsIgnoreCase("")) {
                fakeText = isFocus() ? originalText : INIT_TEXT;
            } else {
                fakeText = "";
                for (int i=0;i<originalText.length();i++) {
                    fakeText += '*';
                }
            }
    
            setText(fakeText);
            super.paint(graphics);          
            setText(originalText);
        }
    }
    

    Above code doesn’t paint a border.

    We need to set a monochrome font for the problem you have mentioned in comment. Here is a sample code:

    MyEditField me = new MyEditField();
    
    try {
        Font font = null;
        FontFamily fontFamily[] = FontFamily.getFontFamilies();
        for (int i=0;i<fontFamily.length; i++) {
            if (fontFamily[i].getName().equalsIgnoreCase("Courier New")) {
            font = fontFamily[i].getFont(FontFamily.SCALABLE_FONT, 
                                Font.getDefault().getHeight());
            me.setFont(font);
            break;
        }
        }
    } catch (Exception e) {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've seen at least one reliable source (a C++ class I took) recommend that
I'm want to parse a custom string format that is persisting an object graphs
If one took say 1000 lines of computer code and instead of the variables
One of the best classes I took in college was Programming Languages where the
I need to move or copy a simple text file from one web site
I'm trying to implement a custom log4net logger/logmanager so that I can add a
I have a custom NSView (it's one of many and they all live inside
I am using jboss-as-7.1.0.Final-SNAPSHOT and trying to set up custom login module that uses
I remember seeing a page on codeproject.com where a developer took one or two
I have one listview that compiles layout template, item template and insert item template.

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.