aaa

1
import javax.swing.*; import java.awt.*; import java.awt.event.*; public class MyPassword extends JFrame implements ActionListener { private JPasswordField passwordBox = new JPasswordField("",10); private JTextField revealedBox = new JTextField("",10); private JButton b1 = new JButton("Reveal"); public MyPassword(String title) { super(title); setDefaultCloseOperation(EXIT_ON_CLOSE); Container c = this.getContentPane(); c.setLayout(new FlowLayout()); c.add(passwordBox); c.add(revealedBox); c.add(b1); passwordBox.requestFocus(); passwordBox.setEchoChar('*'); b1.addActionListener(this); }//constructor public void actionPerformed(ActionEvent e) { String p = String.valueOf(passwordBox.getPassword()); revealedBox.setText(p); }//actionPerformed public static void main(String args[]) { MyPassword mp = new MyPassword("Password Tester"); mp.setSize(400,150); mp.setVisible(true); }//main() }//class

Upload: bruce-arnold

Post on 17-Dec-2015

214 views

Category:

Documents


1 download

DESCRIPTION

password pgm

TRANSCRIPT

import javax.swing.*;

import java.awt.*;

import java.awt.event.*;

public class MyPassword extends JFrame implements ActionListener

{

private JPasswordField passwordBox = new JPasswordField("",10);

private JTextField revealedBox = new JTextField("",10);

private JButton b1 = new JButton("Reveal");

public MyPassword(String title)

{

super(title);

setDefaultCloseOperation(EXIT_ON_CLOSE);

Container c = this.getContentPane();

c.setLayout(new FlowLayout());

c.add(passwordBox);

c.add(revealedBox);

c.add(b1);

passwordBox.requestFocus();

passwordBox.setEchoChar('*');

b1.addActionListener(this);

}//constructor

public void actionPerformed(ActionEvent e)

{

String p = String.valueOf(passwordBox.getPassword());

revealedBox.setText(p);

}//actionPerformed

public static void main(String args[])

{

MyPassword mp = new MyPassword("Password Tester");

mp.setSize(400,150);

mp.setVisible(true);

}//main()

}//class