Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.*;
- import javax.swing.*;
- class PasswordField implements ActionListener{
- JFrame frame;
- JPasswordField pass;
- JButton b1;
- JTextField t1;
- JLabel l1;
- PasswordField(){
- frame = new JFrame();
- frame.setLayout(new GridLayout(2,3));
- pass = new JPasswordField();
- t1 = new JTextField(1);
- l1 = new JLabel("Typed Password:");
- b1 = new JButton("Change Bullet:");
- b1.addActionListener(this);
- pass.addActionListener(this);
- //changing the echo character that is displayed while entering password in JPasswordField
- frame.add(pass);
- frame.add(t1);
- frame.add(b1);
- frame.add(l1);
- frame.setSize(400,400);
- frame.setVisible(true);
- }
- public void actionPerformed(ActionEvent event){
- char a = t1.getText().charAt(0);
- System.out.println(event.getSource());
- pass.setEchoChar(a);
- l1.setText("Typed Password:"+pass.getPassword());
- }
- }
- public class GUI{
- public static void main(String[] args){
- new PasswordField();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement