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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T00:12:55+00:00 2026-06-15T00:12:55+00:00

I have a Password field editor for my JTable. I want to display an

  • 0

I have a Password field editor for my JTable. I want to display an error message if the text length is less than 8 bit when the user clicks to edit another field. I have tried focus listeners. But its not working. Please help me because i have just started workin with java swing.

class PasswordEditor extends DefaultCellEditor 
{

    TextBox m_passWord = new TextBox(); 
    public PasswordEditor() {
        super(new TextBox());
    }

    @Override
    public Object getCellEditorValue() {

        return this.m_passWord.getText();
    }

    @Override
    public Component getTableCellEditorComponent(JTable table,
            Object value, boolean isSelected, int row, int column) {

        Object fieldValue = value;
        if(null == fieldValue)
            fieldValue = Constants.EMPTY_STRING;

        this.m_passWord.addInputMethodListener(new InputMethodListener() {

            @Override
            public void inputMethodTextChanged(InputMethodEvent event)
            {
                // TODO Auto-generated method stub

            }

            @Override
            public void caretPositionChanged(InputMethodEvent event)
            {
                // TODO Auto-generated method stub

            }
        })
        this.m_passWord.addFocusListener(new FocusListener() {

            @Override
            public void focusLost(FocusEvent e)
            {
                if (!e.isTemporary()) {
                      String content = PasswordEditor.this.m_passWord.getText();
                      System.out.println((content));
                }

            }

            @Override
            public void focusGained(FocusEvent e)
            {
                //TODO init
            }
        });

        this.m_passWord.setEditable(true);
        this.m_passWord.setText(fieldValue.toString());
        return this.m_passWord;
    }


}
  • 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-06-15T00:12:56+00:00Added an answer on June 15, 2026 at 12:12 am

    Override stopCellEditing() and implement the condition inside it.

     class PasswordEditor extends DefaultCellEditor 
    {
    
        TextBox m_passWord = new TextBox(); 
        public PasswordEditor() {
            super(new TextBox());
        }
    
                @Override
        public boolean stopCellEditing()
        {
            if(getCellEditorValue().toString().length() < 8)
            {
                JOptionPane.showMessageDialog(UsmUserView.this.m_Parent, "Password Must Be 8 Bytes Long !! Please Check");
                return false;
            }
            fireEditingStopped();
            return true;
        }
    
        @Override
        public Object getCellEditorValue() {
    
            return this.m_passWord.getText();
        }
    
        @Override
        public Component getTableCellEditorComponent(JTable table,
                Object value, boolean isSelected, int row, int column) {
    
            Object fieldValue = value;
            if(null == fieldValue)
                fieldValue = Constants.EMPTY_STRING;
    
            this.m_passWord.setEditable(true);
            this.m_passWord.setText(fieldValue.toString());
            return this.m_passWord;
        }
    
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the password field on page. I want to display text Enter password
I have a password field with text Password and when user clicks, it gets
I have a database field where I want to store my password. In a
i have a User class with a field for the e-mail-address and a password.
My user have a password field such as 0!ZWQ2 saved in the database. I
I want to check the password and i have a password field for that
So I have interesting password validation requirements: When a user signs up, I want
I have a password field with Show password checkbox and I want to write
Here I have a password field: /*********************PASSWORD**********************/ $password = new Zend_Form_Element_Password('password'); $alnumValidator = new
I have some troubles with positioning my label/password field. With this code they both

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.