fill the missing code to run the code import javax.swing.*; import…
Question Answered step-by-step fill the missing code to run the code import javax.swing.*; import… fill the missing code to run the codeimport javax.swing.*; import java.awt.event.*; public class PasswordFieldExample { public static void main(String[] args) { JFrame f=new JFrame(“Password Field Example”); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); JPasswordField value = new JPasswordField(); value.setBounds(100,75,100,30); //———————-(1)// ———————-(2) JLabel l2=new JLabel(“Password:”); l2.setBounds(20,75, 80,30); JButton b = new JButton(“Login”); b.setBounds(100,120, 80,30); f.add(value); f.add(l2); f.add(b); // ——————(3) f.setSize(300,300); f.setLayout(null); f.setVisible(true); b.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if (e.getSource() == b) { String pwdText; //——————–(4) pwdText = value.getText(); //if (pwdText.equals(“james”))——————-(5) JOptionPane.showMessageDialog(f, “Login Successful”); else JOptionPane.showMessageDialog(f, “Invalid Password”); } } }); } } Computer Science Engineering & Technology Java Programming Share QuestionEmailCopy link Comments (0)


