package UI;
import Common.Account;
import Common.Keep_It_Safe;
import javax.swing.JOptionPane;
/*
* NewJFrame2.java
*
* Created on May 31, 2008, 7:29 PM
*/
/**
*
* @author psychok7
*/
public class Frame_Login extends javax.swing.JFrame {
public int flag;
public Account aux2;
public Frame_Main aux;
public Frame_Search UI_search;
/** Creates new form NewJFrame2 */
public Frame_Login(int check,Frame_Main aux,Account aux2) {
initComponents();
this.flag=check;
this.aux=aux;
this.aux2=aux2;
check_condition();
this.setDefaultCloseOperation(Frame_Login.DISPOSE_ON_CLOSE);
this.setResizable(false);
}
public Frame_Login(int check,Frame_Main aux,Frame_Search UI_search,Account aux2) {
initComponents();
this.flag=check;
this.aux=aux;
this.aux2=aux2;
this.UI_search=UI_search;
check_condition();
this.setDefaultCloseOperation(Frame_Login.DISPOSE_ON_CLOSE);
this.setResizable(false);
}
/** 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.
*/
private void check_condition() {
if(aux2!=null){
jTextField1.setText(aux2.get_name());
this.jTextField1.setEnabled(false);
}
if (this.flag==2){ //delete
this.Login_btn.setText("Delete");
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Delete", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION));
}
}
public String getjTextField1(){
return jTextField1.getText();
}
public String getjPasswordField1(){
String password=new String(jPasswordField1.getPassword());
return password;
}
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jTextField1 = new javax.swing.JTextField();
jPasswordField1 = new javax.swing.JPasswordField();
Login_btn = new javax.swing.JButton();
jMenuBar1 = new javax.swing.JMenuBar();
jMenu1 = new javax.swing.JMenu();
Login_btn2 = new javax.swing.JMenuItem();
Exit_btn2 = new javax.swing.JMenuItem();
jMenu2 = new javax.swing.JMenu();
About_btn = new javax.swing.JMenuItem();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Login", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Purisa", 0, 13))); // NOI18N
jLabel1.setFont(new java.awt.Font("Purisa", 0, 13)); // NOI18N
jLabel1.setText("Password:");
jLabel2.setFont(new java.awt.Font("Purisa", 0, 13)); // NOI18N
jLabel2.setText("Name:");
Login_btn.setFont(new java.awt.Font("Purisa", 0, 13)); // NOI18N
Login_btn.setText("Login");
Login_btn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Login_btnActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(55, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel1)
.addComponent(jLabel2))
.addGap(59, 59, 59)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jPasswordField1)
.addComponent(jTextField1, javax.swing.GroupLayout.DEFAULT_SIZE, 71, Short.MAX_VALUE)))
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(127, 127, 127)
.addComponent(Login_btn)))
.addContainerGap(70, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap(20, Short.MAX_VALUE)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(29, 29, 29)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jPasswordField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Login_btn)
.addGap(6, 6, 6))
);
jMenu1.setText("File");
jMenu1.setFont(new java.awt.Font("Purisa", 0, 13)); // NOI18N
jMenu1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu1ActionPerformed(evt);
}
});
Login_btn2.setText("Login");
Login_btn2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Login_btn2ActionPerformed(evt);
}
});
jMenu1.add(Login_btn2);
Exit_btn2.setText("Exit");
Exit_btn2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
Exit_btn2ActionPerformed(evt);
}
});
jMenu1.add(Exit_btn2);
jMenuBar1.add(jMenu1);
jMenu2.setText("Help");
jMenu2.setFont(new java.awt.Font("Purisa", 0, 13)); // NOI18N
jMenu2.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jMenu2ActionPerformed(evt);
}
});
About_btn.setText("About");
About_btn.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
About_btnActionPerformed(evt);
}
});
jMenu2.add(About_btn);
jMenuBar1.add(jMenu2);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void Login_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Login_btnActionPerformed
// TODO add your handling code here:
if (this.flag==1){
//System.out.println("login");
Keep_It_Safe obj=new Keep_It_Safe (this);
obj.SignIn();
Frame_Output output=new Frame_Output();
if((obj.getOutput().equals("This Account Does Not Exist, Please Create A New User"))||(obj.getOutput().equals("Password Incorrect,Try Again"))||(obj.getOutput().equals("The Account Does Not Exist.Please Create A New Account")))
JOptionPane.showMessageDialog(null,obj.getOutput()+"\n");
else{
output.setVisible(true);
output.setOutput(output.getOutput()+obj.getOutput());
}
this.dispose();
}
else if (this.flag==2){
//System.out.println("delete");
Keep_It_Safe obj=new Keep_It_Safe (this);
obj.delete_account(this.aux);
//obj.delete_all_accounts();
JOptionPane.showMessageDialog(null,obj.getOutput()+"\n"+obj.getOutput2()+"\n");
this.UI_search.setVisible(true);
this.UI_search.createNodes();
this.dispose();
}
}//GEN-LAST:event_Login_btnActionPerformed
private void jMenu2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu2ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMenu2ActionPerformed
private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_jMenu1ActionPerformed
private void Login_btn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Login_btn2ActionPerformed
// TODO add your handling code here:
if (this.flag==1){
//System.out.println("login");
Keep_It_Safe obj=new Keep_It_Safe (this);
obj.SignIn();
Frame_Output output=new Frame_Output();
if((obj.getOutput().equals("This Account Does Not Exist, Please Create A New User"))||(obj.getOutput().equals("Password Incorrect,Try Again"))||(obj.getOutput().equals("The Account Does Not Exist.Please Create A New Account")))
JOptionPane.showMessageDialog(null,obj.getOutput()+"\n");
else{
output.setVisible(true);
output.setOutput(output.getOutput()+obj.getOutput());
}
this.dispose();
}
else if (this.flag==2){
//System.out.println("delete");
Keep_It_Safe obj=new Keep_It_Safe (this);
obj.delete_account(this.aux);
//obj.delete_all_accounts();
JOptionPane.showMessageDialog(null,obj.getOutput()+"\n"+obj.getOutput2()+"\n");
this.UI_search.setVisible(true);
this.UI_search.createNodes();
this.dispose();
}
}//GEN-LAST:event_Login_btn2ActionPerformed
private void Exit_btn2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Exit_btn2ActionPerformed
// TODO add your handling code here:
System.exit(0);
}//GEN-LAST:event_Exit_btn2ActionPerformed
private void About_btnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_About_btnActionPerformed
// TODO add your handling code here:
new Frame_About().setVisible(true);
}//GEN-LAST:event_About_btnActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Frame_Login(0,null,null).setVisible(true); //when running the window
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JMenuItem About_btn;
private javax.swing.JMenuItem Exit_btn2;
private javax.swing.JButton Login_btn;
private javax.swing.JMenuItem Login_btn2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField jPasswordField1;
private javax.swing.JTextField jTextField1;
// End of variables declaration//GEN-END:variables
}