Ask your own question, for FREE!
Computer Science
OpenStudy (anonymous):

@Ishaan94 and @apoorvk

OpenStudy (anonymous):

import javax.swing.*; import java.awt.*; import java.awt.event.*; public class JPasswordEvent implements ActionListener,WindowListener { JFrame f,f2; JLabel label; JPasswordField pField; JButton b,b2; public JPasswordEvent(JFrame pa) { f2= pa; f = new JFrame("Introducing JPasswordField"); f.setSize(400, 400); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setLocationRelativeTo(null); label = new JLabel("Enter your Password"); pField = new JPasswordField(20); pField.setEchoChar('*'); pField.addActionListener(this); b = new JButton("GO BACK"); b2= new JButton("ENTER"); Container c = f.getContentPane(); FlowLayout flow = new FlowLayout(); c.setLayout(flow); b.addActionListener(this); b2.addActionListener(this); f.addWindowListener(this); f.add(label); f.add(pField); f.add(b2); f.add(b); f.setVisible(true); } /*public static void main(String args[]) { new JPasswordEvent(); }*/ public void actionPerformed(ActionEvent event) { if(event.getSource()==b){ if(f2 != null) { f2.setVisible(true); f.dispose(); } else {JOptionPane.showMessageDialog(null, "No Main Frame exists.");}} if(event.getSource()==b2){ char[] password = pField.getPassword(); String pass = String.valueOf(password); if(pass.equals("annas21")){ JOptionPane.showMessageDialog(null, "Authorization aproved!"); f.dispose(); new RegistrationForm(f2); } else JOptionPane.showMessageDialog(null, "Invalid password !");}} public void windowClosing(WindowEvent x) { if(f2 != null) { f2.setVisible(true); f.dispose(); } else System.exit(1); } public void windowOpened(WindowEvent x){}; public void windowClosed(WindowEvent x){}; public void windowActivated(WindowEvent x){}; public void windowDeactivated(WindowEvent x){}; public void windowDeiconified(WindowEvent x) {}; public void windowIconified(WindowEvent x){}; }

OpenStudy (anonymous):

Wow...im just beginning java...havent got to gui

OpenStudy (anonymous):

thanks actually i m in 4th semester of software engineering

OpenStudy (anonymous):

oh...ive just done 2nd sem..electronics

OpenStudy (anonymous):

nice dude :)

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!