I'm currently working on some code for an applet and I have it up and working but am trying to get rid of the extra JOptionPane Message Dialogs and replace them with just a simple JLabel within the already running applet.
Here is my current code:
import javax.swing.*; import java.awt.event.*; import java.awt.*; public class JPasswordC extends JApplet implements ActionListener { Container PW = getContentPane(); JLabel password = new JLabel("Enter Password(and click OK):"); Font font1 = new Font("Times New Roman", Font.BOLD, 18); JTextField input = new JTextField(7); JButton enter = new JButton("OK"); public void start() { PW.add(password); password.setFont(font1); PW.add(input); PW.add(enter); PW.setLayout(new FlowLayout()); enter.addActionListener(this); } public void actionPerformed(ActionEvent e) { String pass1 = input.getText(); String passwords[] = {"Rosebud", "Redrum", "Jason", "Surrender", "Dorothy"}; for(int i=0;i<passwords.length;i++) { if (pass1.equalsIgnoreCase(passwords[i])) { JOptionPane.showMessageDialog(null, "Access Granted"); } else { JOptionPane.showMessageDialog(null, "Access Denied"); } } }
The part I'm trying to isolate is in the actionPerformed after the array runs. I currently have it having the Message Dialogs popping based on the if else statement but as I mentioned prior I'd rather clean it up and just add a JLabel to it.