Ask your own question, for FREE!
Computer Science 20 Online
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!
Latest Questions
kaelynw: starting to draw a hand
1 day ago 16 Replies 2 Medals
Twaylor: Rate it :D (Took 2 days)
2 days ago 7 Replies 0 Medals
XShawtyX: Art, Short Writing Assignment: Imagining Landscapes
1 hour ago 6 Replies 1 Medal
XShawtyX: Chemistry, Help ud83dude4fud83cudffe
2 days ago 13 Replies 1 Medal
kaelynw: tried a lil smt, the arm is off but i like the other stuff
3 days ago 27 Replies 3 Medals
kaelynw: art igg
3 days ago 14 Replies 1 Medal
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!