Creating TextField to Handle Passwords

Creating TextField to Handle Passwords

How do I create a TextField that handles a password?What are the KEY_ACTION events associated with it?

The setEchoCharacter() method within the TextField class allows youto do precisely that. It lets you specify the character that isto display on the screen within the textfield area when the usertypes something in it. So if you set that character to somethinglike ‘*’, the password doesn’t appear on the screen.For example, the following applet creates a name and passwordprompt. For the user name, the characters are echoed back normally, butfor the password only asterisks appear. To know when theuser is done entering a password, you can simply watch for ACTION_EVENTevents in the action() method of the applet.

import java.applet.*;import java.awt.*;public class PasswordPrompt extends Applet {       TextField username, password;       public void init() {               setLayout(new BorderLayout());               // add a username text field               Panel namePanel = new Panel();               Label nameLabel = new Label(“User name: “);               namePanel.add(nameLabel);               username = new TextField(20);               namePanel.add(username);               add(“North”, namePanel);               // add a password text field               Panel pwPanel = new Panel();               Label pwLabel = new Label(“Password: “);               pwPanel.add(pwLabel);               password = new TextField(20);               // set the echo character to be an asterisk               password.setEchoCharacter(‘*’);               pwPanel.add(password);               add(“South”, pwPanel);       }       public synchronized boolean action(Event e, Object what) {               if ( == password && == Event.ACTION_EVENT) {                       // the user has pressed enter in the password                       // text field.  You can choose to catch ACTION_EVENTs                       // for the username area as well.                       showStatus(“User: ” + username.getText() +                                       “, Password: ” + password.getText());                       return true;               }               return false;       }}

Share the Post:
Heading photo, Metadata.

What is Metadata?

What is metadata? Well, It’s an odd concept to wrap your head around. Metadata is essentially the secondary layer of data that tracks details about the “regular” data. The regular

XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of