import java.awt.event.ActionEvent; import java.awt.BorderLayout; import java.awt.GridLayout; import java.awt.Dimension; import javax.swing.JFrame; import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.BorderFactory; import java.util.Properties; public class pmFormLogin extends pmAbstractFormGetAccount { private final String strScriptHandler = strBase + "profileMakerLoginScript.pl"; public pmFormLogin (JFrame mainApp) { super(mainApp, "Login", new Dimension(170, 140)); cmdLogin.setText("Login"); panGrid = new JPanel(new GridLayout(2, 2, 2, 2)); panRoot.add(panGrid, BorderLayout.NORTH); panGrid.add(lblAlias); panGrid.add(txtAlias); panGrid.add(lblPass); panGrid.add(txtPass); panGrid.setBorder(BorderFactory.createTitledBorder(BorderFactory.createLineBorder(clrTitledBorder), "Login Details")); } public void actionPerformed (ActionEvent e) { if (e.getSource() == cmdLogin) { String strAlias = txtAlias.getText(); String strPass = ""; try { strPass = new String(txtPass.getPassword()); } catch (NullPointerException ex) { strPass = new String(""); } finally { txtPass.setText(""); } if (strAlias.equals("") || strPass.equals("")) { JOptionPane.showMessageDialog(mainApp, "Both the alias and password are required", "Missing fields", JOptionPane.WARNING_MESSAGE); } else if (testpmValidData(strAlias, strPass)) { Properties props = null; try { props = performConnection(strScriptHandler, strAlias, strPass); } catch (dialogueException ex) { ex.displayError(mainApp); } if (props.getProperty("loginSuccess").equalsIgnoreCase("true")) { isLoggedIn = true; JOptionPane.showMessageDialog(mainApp, "You have been successfully logged in", "Logged in", JOptionPane.INFORMATION_MESSAGE); this.setVisible(false); } else { JOptionPane.showMessageDialog(mainApp, (String)props.getProperty("errorMsg"), (String)props.getProperty("errorMsgTitle"), JOptionPane.WARNING_MESSAGE); } } } else if (e.getSource() == cmdCancel) { this.setVisible(false); } } }