package graderforms.resources; /* * To change this template, choose Tools | Templates * and open the template in the editor. */ /* * Login.java * * Created on Nov 14, 2009, 10:38:24 PM */ /** * * @author Kevin */ public class Login extends javax.swing.JDialog { /** Creates new form Login */ public Login(java.awt.Frame parent, boolean modal) { super(parent, modal); int x, y; initComponents(); x=this.getWidth(); y=this.getHeight(); this.setLocationRelativeTo(null); this.setLocation(this.getX()-x/8, this.getY()-y/8); this.getRootPane().setDefaultButton(btnLogin); } /** 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() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); txtUsername = new javax.swing.JTextField(); jCheckBox1 = new javax.swing.JCheckBox(); jLabel3 = new javax.swing.JLabel(); comboServer = new javax.swing.JComboBox(); btnLogin = new javax.swing.JButton(); btnReset = new javax.swing.JButton(); txtPassword = new javax.swing.JPasswordField(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setTitle("PolyGrade Login"); jLabel1.setText("Username:"); jLabel1.setName("jLabel1"); // NOI18N jLabel2.setText("Password:"); jLabel2.setName("jLabel2"); // NOI18N txtUsername.setName("txtUsername"); // NOI18N jCheckBox1.setText("Remember Me"); jCheckBox1.setName("jCheckBox1"); // NOI18N jLabel3.setText("Server:"); jLabel3.setName("jLabel3"); // NOI18N comboServer.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "vogon", "falcon", "hornet" })); comboServer.setName("comboServer"); // NOI18N btnLogin.setText("Login"); btnLogin.setName("btnLogin"); // NOI18N btnLogin.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoginActionPerformed(evt); } }); btnReset.setText("Reset"); btnReset.setName("btnReset"); // NOI18N btnReset.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnResetActionPerformed(evt); } }); txtPassword.setName("txtPassword"); // NOI18N 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() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jCheckBox1) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel2) .addComponent(jLabel1)) .addGap(8, 8, 8) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtPassword, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE) .addComponent(txtUsername, javax.swing.GroupLayout.DEFAULT_SIZE, 152, Short.MAX_VALUE))) .addGroup(layout.createSequentialGroup() .addComponent(jLabel3) .addGap(26, 26, 26) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addComponent(btnLogin) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(btnReset)) .addComponent(comboServer, 0, 150, Short.MAX_VALUE)))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtUsername, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jCheckBox1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3) .addComponent(comboServer, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnReset) .addComponent(btnLogin)) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) ); pack(); }// //GEN-END:initComponents private void btnLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnLoginActionPerformed this.setVisible(false); (new GradeSheet()).setVisible(true); // String loginID=txtUsername.getText(); // if((loginID.equals("gfisher") || // loginID.equals("kewatson") || // loginID.equals("kowen") || // loginID.equals("bupp") || // loginID.equals("cbrazins") || // loginID.equals("jtchen")) && // txtPassword.getPassword().length>0){ // this.setVisible(false); // (new GradeSheet()).setVisible(true); // } }//GEN-LAST:event_btnLoginActionPerformed private void btnResetActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnResetActionPerformed txtUsername.setText(""); txtPassword.setText(""); jCheckBox1.setSelected(false); comboServer.setSelectedIndex(0); }//GEN-LAST:event_btnResetActionPerformed /** * @param args the command line arguments */ public static void main(String args[]) { java.awt.EventQueue.invokeLater(new Runnable() { public void run() { Login dialog = new Login(new javax.swing.JFrame(), true); dialog.addWindowListener(new java.awt.event.WindowAdapter() { 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.JButton btnLogin; private javax.swing.JButton btnReset; private javax.swing.JComboBox comboServer; private javax.swing.JCheckBox jCheckBox1; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JPasswordField txtPassword; private javax.swing.JTextField txtUsername; // End of variables declaration//GEN-END:variables }