Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- package proiect;
- import com.sun.glass.events.KeyEvent;
- import javax.swing.JOptionPane;
- /**
- *
- * @author studlab136a
- */
- public class Login extends javax.swing.JFrame {
- /**
- * Creates new form Login
- */
- public Login() {
- initComponents();
- }
- /**
- * 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")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- cancel = new javax.swing.JButton();
- login = new javax.swing.JButton();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel4 = new javax.swing.JLabel();
- username = new javax.swing.JTextField();
- password = new javax.swing.JPasswordField();
- reset = new javax.swing.JButton();
- setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
- cancel.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- cancel.setText("Cancel");
- cancel.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- cancelActionPerformed(evt);
- }
- });
- login.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- login.setText("Login");
- login.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- loginActionPerformed(evt);
- }
- });
- jLabel2.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel2.setText("Username:");
- jLabel3.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- jLabel3.setText("Password:");
- jLabel4.setFont(new java.awt.Font("Tahoma", 0, 16)); // NOI18N
- jLabel4.setText("Login");
- username.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- username.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- usernameActionPerformed(evt);
- }
- });
- password.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- password.addKeyListener(new java.awt.event.KeyAdapter() {
- public void keyPressed(java.awt.event.KeyEvent evt) {
- passwordKeyPressed(evt);
- }
- });
- reset.setFont(new java.awt.Font("Tahoma", 0, 14)); // NOI18N
- reset.setText("Reset");
- reset.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- resetActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(layout.createSequentialGroup()
- .addGap(129, 129, 129)
- .addComponent(jLabel4))
- .addGroup(layout.createSequentialGroup()
- .addGap(65, 65, 65)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 73, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(33, 33, 33)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(username)
- .addComponent(password))))
- .addGap(21, 21, 21))
- .addGroup(layout.createSequentialGroup()
- .addGap(28, 28, 28)
- .addComponent(cancel)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 13, Short.MAX_VALUE)
- .addComponent(reset)
- .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(login, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addGap(60, 60, 60))
- );
- layout.setVerticalGroup(
- layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
- .addGap(33, 33, 33)
- .addComponent(jLabel4)
- .addGap(43, 43, 43)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(username, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(41, 41, 41)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(password, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(70, 70, 70)
- .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(cancel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(reset, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(login))
- .addGap(42, 42, 42))
- );
- pack();
- }// </editor-fold>
- private void usernameActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void cancelActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- dispose();
- }
- private void resetActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- username.setText("");
- password.setText("");
- }
- private void passwordKeyPressed(java.awt.event.KeyEvent evt) {
- // TODO add your handling code here:
- if(evt.getKeyCode()==KeyEvent.VK_ENTER)
- {
- String user=username.getText();
- String pass=password.getText();
- if((user.contains("ovidiu"))&&(pass.contains("password")))
- {
- JOptionPane.showMessageDialog(null, "A mers");
- }
- else{
- JOptionPane.showMessageDialog(null, "Nu a mers");
- }
- }
- }
- private void loginActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- String user=username.getText();
- String pass=password.getText();
- if((user.contains("ovidiu"))&&(pass.contains("password")))
- {
- JOptionPane.showMessageDialog(null, "A mers");
- }
- else{
- JOptionPane.showMessageDialog(null, "Nu a mers");
- }
- }
- /**
- * @param args the command line arguments
- */
- public static void main(String args[]) {
- /* Set the Nimbus look and feel */
- //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
- /* 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(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (InstantiationException ex) {
- java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (IllegalAccessException ex) {
- java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- } catch (javax.swing.UnsupportedLookAndFeelException ex) {
- java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
- }
- //</editor-fold>
- /* Create and display the form */
- java.awt.EventQueue.invokeLater(new Runnable() {
- public void run() {
- new Login().setVisible(true);
- }
- });
- }
- // Variables declaration - do not modify
- private javax.swing.JButton cancel;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JButton login;
- private javax.swing.JPasswordField password;
- private javax.swing.JButton reset;
- private javax.swing.JTextField username;
- // End of variables declaration
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement