Please take time to read the code disclaimer.
package silverlining;
import backend.*;
import clerksystem.*;
import employeesystem.*;
import javax.swing.*;
import websytem.*;
/**
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
* LoginDialog.java
*
* Created on Nov 28, 2011, 4:52:51 PM
*/
/**
*
* @author Kent
*/
public class LoginDialog extends javax.swing.JFrame {
private AccountGenerator ag = new AccountGenerator();
/**
* Creates new form LoginDialog
*/
public LoginDialog() {
initComponents();
String slogan1 = "Our Challenge:";
String slogan2 = "We must move forward and delight our customer through Operational Excellence and Innovation";
String slogan3 = "with Committed and Capable People achieving Growth and fulfilling the Vision of assuring a";
String slogan4 = "future better beyond our present best.";
sloganLabel1.setText(slogan1);
sloganLabel2.setText(slogan2);
sloganLabel3.setText(slogan3);
sloganLabel4.setText(slogan4);
StaticClass.centerAndPack(this);
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// //GEN-BEGIN:initComponents
private void initComponents() {
java.awt.GridBagConstraints gridBagConstraints;
logo = new javax.swing.JLabel();
loginPanel = new javax.swing.JPanel();
welcomeLabel = new javax.swing.JLabel();
loginButton1 = new javax.swing.JButton();
credentialsPanel = new javax.swing.JPanel();
loginComboBox = new javax.swing.JComboBox();
usernameTextField = new javax.swing.JTextField();
usernameLabel = new javax.swing.JLabel();
passwordLabel = new javax.swing.JLabel();
passwordTextField = new javax.swing.JPasswordField();
slognaPanel = new javax.swing.JPanel();
sloganLabel1 = new javax.swing.JLabel();
sloganLabel2 = new javax.swing.JLabel();
sloganLabel3 = new javax.swing.JLabel();
sloganLabel4 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("SLEEK Signin");
getContentPane().setLayout(new java.awt.GridBagLayout());
logo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/SilverLiningLogo25%.jpg"))); // NOI18N
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(logo, gridBagConstraints);
loginPanel.setLayout(new java.awt.GridBagLayout());
welcomeLabel.setText("Welcome to SLEEK. Please login.");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
loginPanel.add(welcomeLabel, gridBagConstraints);
loginButton1.setText("Login");
loginButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
loginButton1ActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
loginPanel.add(loginButton1, gridBagConstraints);
credentialsPanel.setLayout(new java.awt.GridBagLayout());
loginComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Salesperson", "Clerk", "Web (DEMO)" }));
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.gridwidth = 2;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
credentialsPanel.add(loginComboBox, gridBagConstraints);
usernameTextField.setMaximumSize(new java.awt.Dimension(60, 30));
usernameTextField.setMinimumSize(new java.awt.Dimension(60, 30));
usernameTextField.setPreferredSize(new java.awt.Dimension(60, 30));
usernameTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
usernameTextFieldActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 1;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 56;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
credentialsPanel.add(usernameTextField, gridBagConstraints);
usernameLabel.setText("Username:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
credentialsPanel.add(usernameLabel, gridBagConstraints);
passwordLabel.setText("Password:");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
credentialsPanel.add(passwordLabel, gridBagConstraints);
passwordTextField.setMaximumSize(new java.awt.Dimension(60, 30));
passwordTextField.setMinimumSize(new java.awt.Dimension(60, 30));
passwordTextField.setPreferredSize(new java.awt.Dimension(60, 30));
passwordTextField.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
passwordTextFieldActionPerformed(evt);
}
});
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 1;
gridBagConstraints.gridy = 2;
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.ipadx = 56;
gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
credentialsPanel.add(passwordTextField, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(5, 5, 5, 5);
loginPanel.add(credentialsPanel, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.insets = new java.awt.Insets(10, 10, 10, 10);
getContentPane().add(loginPanel, gridBagConstraints);
slognaPanel.setLayout(new java.awt.GridBagLayout());
sloganLabel1.setText("slogan1");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 0;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
slognaPanel.add(sloganLabel1, gridBagConstraints);
sloganLabel2.setText("slogan2");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 1;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
slognaPanel.add(sloganLabel2, gridBagConstraints);
sloganLabel3.setText("slogan3");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
slognaPanel.add(sloganLabel3, gridBagConstraints);
sloganLabel4.setText("slogan4");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 3;
gridBagConstraints.anchor = java.awt.GridBagConstraints.LINE_START;
gridBagConstraints.insets = new java.awt.Insets(2, 2, 2, 2);
slognaPanel.add(sloganLabel4, gridBagConstraints);
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.gridx = 0;
gridBagConstraints.gridy = 2;
gridBagConstraints.insets = new java.awt.Insets(0, 0, 10, 0);
getContentPane().add(slognaPanel, gridBagConstraints);
pack();
}// //GEN-END:initComponents
private void passwordTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_passwordTextFieldActionPerformed
System.out.println("Password Action");
login(loginComboBox.getSelectedIndex());
}//GEN-LAST:event_passwordTextFieldActionPerformed
private void usernameTextFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_usernameTextFieldActionPerformed
System.out.println("Username Action");
login(loginComboBox.getSelectedIndex());
}//GEN-LAST:event_usernameTextFieldActionPerformed
private void loginButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_loginButton1ActionPerformed
System.out.println("Login Button");
login(loginComboBox.getSelectedIndex());
}//GEN-LAST:event_loginButton1ActionPerformed
/**
* This logs the user in
* @param type
*/
public void login(int type) {
JFrame selectedFrame = new SalespersonGUI(ag);
System.out.println(type);
if (type == 0) {
selectedFrame = new SalespersonGUI(ag);
System.out.println("Salesperson");
} else if (type == 1) {
selectedFrame = new ClerkGUI(ag);
System.out.println("Clerk");
} else if (type == 2) {
selectedFrame = new WebGUI(ag);
System.out.println("Web");
}
selectedFrame.setVisible(true);
this.dispose();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/** Set the Nimbus look and feel */
//
/** If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(LoginDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(LoginDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(LoginDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(LoginDialog.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//
/** Create and display the dialog */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
LoginDialog dialog = new LoginDialog();
dialog.addWindowListener(new java.awt.event.WindowAdapter() {
@Override
public void windowClosing(java.awt.event.WindowEvent e) {
System.exit(0);
}
});
dialog.setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JPanel credentialsPanel;
private javax.swing.JButton loginButton1;
private javax.swing.JComboBox loginComboBox;
private javax.swing.JPanel loginPanel;
private javax.swing.JLabel logo;
private javax.swing.JLabel passwordLabel;
private javax.swing.JPasswordField passwordTextField;
private javax.swing.JLabel sloganLabel1;
private javax.swing.JLabel sloganLabel2;
private javax.swing.JLabel sloganLabel3;
private javax.swing.JLabel sloganLabel4;
private javax.swing.JPanel slognaPanel;
private javax.swing.JLabel usernameLabel;
private javax.swing.JTextField usernameTextField;
private javax.swing.JLabel welcomeLabel;
// End of variables declaration//GEN-END:variables
}