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

  • SEARCH
  • Home
  • 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 6360683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:40:48+00:00 2026-05-24T23:40:48+00:00

I am developing the logic to build a good password strength checker for my

  • 0

I am developing the logic to build a good password strength checker for my login form,but the problem is how to express strength of password entered ? I am using java and I am using this approach:

  1. using JProgressBar as strength meter,it changes color when focus from JPasswordField is lost or when a key is released in JPasswordField (this gives quicker response).

  2. Can I use Swing Worker on this to make it better ? I have never used it so can anybody help me with that if it is best way.

Please forgive me for long sentences.

See Image below:


This image below shows what I want to achieve

  • 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-24T23:40:48+00:00Added an answer on May 24, 2026 at 11:40 pm

    no SwingWorker doesn’t make me sence in this case, that’s just and about DocumentListener

    NOTICE: this example not about How to check password strenght, just how to listening for changes from JPasswordField and redirect output to the JProgressBar

    enter image description hereenter image description hereenter image description here

    import java.awt.GridLayout;
    import javax.swing.*;
    import javax.swing.event.DocumentEvent;
    import javax.swing.event.DocumentListener;
    
    public class TextLabelMirror {
    
        private JPanel mainPanel = new JPanel();
        private JPasswordField field = new JPasswordField(20);
        private JLabel label = new JLabel();
        private JLabel labelLength = new JLabel();
        private JProgressBar progressBar = new JProgressBar(0, 20);
    
        public TextLabelMirror() {
            field.getDocument().addDocumentListener(new DocumentListener() {
    
                @Override
                public void changedUpdate(DocumentEvent e) {
                    updateLabel(e);
                }
    
                @Override
                public void insertUpdate(DocumentEvent e) {
                    updateLabel(e);
                }
    
                @Override
                public void removeUpdate(DocumentEvent e) {
                    updateLabel(e);
                }
    
                private void updateLabel(DocumentEvent e) {
                    String text = field.getText();//just example getText() is Depreciated !!!
                    label.setText(text);
                    labelLength.setText(" Psw Lenght -> " + text.length());
                    if (text.length() < 1) {
                        progressBar.setValue(0);
                    } else {
                        progressBar.setValue(text.length());
                    }
                }
            });
            mainPanel.setLayout(new GridLayout(4, 0, 10, 0));
            mainPanel.add(field);
            mainPanel.add(label);
            mainPanel.add(labelLength);
            mainPanel.add(progressBar);
        }
    
        public JComponent getComponent() {
            return mainPanel;
        }
    
        private static void createAndShowUI() {
            JFrame frame = new JFrame("Password Strength Checker");
            frame.getContentPane().add(new TextLabelMirror().getComponent());
            frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
            frame.pack();
            frame.setLocationRelativeTo(null);
            frame.setVisible(true);
        }
    
        public static void main(String[] args) {
            java.awt.EventQueue.invokeLater(new Runnable() {
    
                @Override
                public void run() {
                    createAndShowUI();
                }
            });
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just ran into a problem while developing a login system. I build a
I'm developing an iPhone application where I wish to authenticate (login form) on a
Developing a heavily XML-based Java-application, I recently encountered an interesting problem on Ubuntu Linux.
I am developing a user login authentication, using jsp/servlets and glassfish v3. Basically the
I need some feedback with some programming logic. I'm developing a TCP Server using
I'm currently developing an ASP.NET website, and I'm using ASP.NET's built-in Login control with
I am developing a data driven website and quite a lot of programming logic
I am developing my login for my new homepage. Now I found out, that
I am developing a PHP-based login system. Each user has an ID(a number) and
I'm developing a standalone custom registry, custom login portlet, and custom profile portlet for

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.