Results 1 to 5 of 5
  1. #1
    mharsijamel is offline Member
    Join Date
    Aug 2011
    Posts
    60
    Rep Power
    0

    Default authentification error

    i have two classes:
    -autentifier
    -shrimp

    shrimp was the first one, i added "authentifier" to add authentification
    i wrote this method:
    Java Code:
    int i;
            for (i = 0; i < logins.length; i++)
            {
                
                if (text_login.getText().equalsIgnoreCase(logins[i]))
                {
                    
                    if (!text_password.getText().equalsIgnoreCase(passwd[i]))
                    {
                        System.out.println(text_password.getText());
                        System.out.println(passwd[i]);
                        JOptionPane.showMessageDialog(null, "Invalid password", "Dialog Message", JOptionPane.ERROR_MESSAGE);
                        text_password.setText("");
                        break;
    
                    }
                    else
                    {
                        System.out.println("3");
                        new Shrimp();
                        
                        this.setVisible(true);
                        break;
                    }
                }
    
            }
            if (i == logins.length)
            {
                JOptionPane.showMessageDialog(null, "Invalid login", "Dialog Message", JOptionPane.ERROR_MESSAGE);
                text_login.setText("");
    
            }
    if authentification was good, my java program shows "build successful" and stop run, or it crashes

  2. #2
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: authentification error

    You do not think it would be wise to give out an error description or code that compiles, right?
    I like likes!

  3. #3
    mharsijamel is offline Member
    Join Date
    Aug 2011
    Posts
    60
    Rep Power
    0

    Default Re: authentification error

    there is no error
    it just shows, after authentification success, build successfull, and it don't run "shrimp"
    if i made "shrimp" like start class, it run without problem

  4. #4
    Sierra is offline AN21XX
    Join Date
    Mar 2012
    Location
    Munich
    Posts
    297
    Rep Power
    3

    Default Re: authentification error

    Sorry, your information is not sufficient to tell you what is wrong. How should we tell you what is wrong with your starting class if we do not even know what it looks like?
    MAybe someone else could read the crystal ball for you.
    I like likes!

  5. #5
    mharsijamel is offline Member
    Join Date
    Aug 2011
    Posts
    60
    Rep Power
    0

    Default Re: authentification error

    this is the shrimp class; shis class if it is the run class, it run without problem

    Java Code:
    /**
     * Copyright 1998-2007, CHISEL Group, University of Victoria, Victoria, BC, Canada.
     * All rights reserved.
     */
    package ca.uvic.csr.shrimp;
    
    import ca.uvic.csr.shrimp.ShrimpApplication.StandAloneApplication.StandAloneApplication;
    import ca.uvic.csr.shrimp.resource.ResourceHandler;
    import java.awt.event.WindowAdapter;
    import java.awt.event.WindowEvent;
    import java.net.URI;
    import javax.swing.JFrame;
    import javax.swing.SwingUtilities;
    import javax.swing.UIManager;
    
    /**
     * Optional Command Line Parameter:
     *	<i>filename</i> Opens this file immediately as program starts up.
     */
    public class Shrimp {
    
        /**
         * "The" main method to launch stand-alone shrimp
         * @param args Optional Command Line Parameter: <i>filename</i> Opens this file immediately as program starts up.
         */
        public static void main(String[] args) {
    		try {
    			UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    		} catch (Exception e) {
    			e.printStackTrace();
    		}
    		System.out.println("Starting Shrimp...");
    		System.out.println("java.version=" + System.getProperty("java.version"));
    		System.out.println("os.name=" + System.getProperty("os.name"));
    		
    
    		final StandAloneApplication application = new StandAloneApplication();
            JFrame frame = application.createParentFrame();
            application.initialize(frame);
            frame.setVisible(true);
    		if (args.length > 0) {
    		    String fileName = args[0];
    		    final URI uri = ResourceHandler.getFileURI(fileName);
    		    if (uri != null) {
    				SwingUtilities.invokeLater(new Runnable () {
    					public void run() {
    						application.openProject(uri);
    					}
    				});
    		    } else {
    		        System.err.println("File '" + fileName + "' does not exist.");
    		    }
    		}
    
    		frame.addWindowListener(new WindowAdapter() {
                @Override
    			public void windowClosed(WindowEvent evt) {
             		// Exit without an error
    				System.exit(0);
    			}
    		});
        }
    }
    when i use authentification class as start class, it does not show shrimp if authntification success:
    Java Code:
    /*
     * To change this template, choose Tools | Templates
     * and open the template in the editor.
     */
    
    /*
     * Authentifier.java
     *
     * Created on 8 dأc. 2009, 22:01:53
     */
    
    package ca.uvic.csr.shrimp.util;
    
    import ca.uvic.csr.shrimp.Shrimp;
    import java.awt.Font;
    import javax.swing.ImageIcon;
    import javax.swing.JOptionPane;
    
    /**
     *
     * @author Administrateur
     */
    public class Authentifier extends javax.swing.JFrame
    {
        /** Creates new form Authentifier */
        String[] logins=new String[2];
    
        String[] passwd=new String[2];
    
        Font f = new Font("Times New Roman ", 1, 12);
    
        public Authentifier() 
        {
            this.setIconImage(new ImageIcon("images/DW.jpg").getImage());
            logins[0]="SalesManager";
            logins[1]="SupplyManager";
            passwd[0]="jamel";
            passwd[1]="jamel";
            setTitle("Authentification");
            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() {
    
            panel_authent = new javax.swing.JPanel();
            label_login = new javax.swing.JLabel();
            label_pwd = new javax.swing.JLabel();
            text_login = new javax.swing.JTextField();
            buttonOK = new javax.swing.JButton();
            buttonCancel = new javax.swing.JButton();
            text_password = new javax.swing.JPasswordField();
    
            setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
            setBackground(new java.awt.Color(255, 204, 153));
    
            panel_authent.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Authentification", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Times New Roman", 2, 18), new java.awt.Color(102, 0, 102))); // NOI18N
    
            label_login.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
            label_login.setText("Login name:");
    
            label_pwd.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
            label_pwd.setText("Password:");
    
            text_login.setFont(new java.awt.Font("Times New Roman", 1, 12)); // NOI18N
    
            buttonOK.setText("OK");
            buttonOK.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    buttonOKActionPerformed(evt);
                }
            });
    
            buttonCancel.setText("Cancel");
            buttonCancel.addActionListener(new java.awt.event.ActionListener() {
                public void actionPerformed(java.awt.event.ActionEvent evt) {
                    buttonCancelActionPerformed(evt);
                }
            });
    
            javax.swing.GroupLayout panel_authentLayout = new javax.swing.GroupLayout(panel_authent);
            panel_authent.setLayout(panel_authentLayout);
            panel_authentLayout.setHorizontalGroup(
                panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_authentLayout.createSequentialGroup()
                    .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(panel_authentLayout.createSequentialGroup()
                            .addContainerGap()
                            .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                .addComponent(label_login)
                                .addComponent(label_pwd)))
                        .addGroup(panel_authentLayout.createSequentialGroup()
                            .addGap(49, 49, 49)
                            .addComponent(buttonOK)))
                    .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                    .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_authentLayout.createSequentialGroup()
                            .addComponent(buttonCancel)
                            .addGap(44, 44, 44))
                        .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panel_authentLayout.createSequentialGroup()
                            .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                .addComponent(text_password, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE)
                                .addComponent(text_login, javax.swing.GroupLayout.DEFAULT_SIZE, 159, Short.MAX_VALUE))
                            .addContainerGap())))
            );
    
            panel_authentLayout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonCancel, buttonOK});
    
            panel_authentLayout.setVerticalGroup(
                panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(panel_authentLayout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(label_login)
                        .addComponent(text_login, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(18, 18, 18)
                    .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(label_pwd)
                        .addComponent(text_password, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGap(30, 30, 30)
                    .addGroup(panel_authentLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(buttonOK)
                        .addComponent(buttonCancel))
                    .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
            );
    
            javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
            getContentPane().setLayout(layout);
            layout.setHorizontalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(81, 81, 81)
                    .addComponent(panel_authent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(90, Short.MAX_VALUE))
            );
            layout.setVerticalGroup(
                layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                .addGroup(layout.createSequentialGroup()
                    .addGap(65, 65, 65)
                    .addComponent(panel_authent, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addContainerGap(65, Short.MAX_VALUE))
            );
    
            pack();
        }// </editor-fold>                        
    
        private void buttonOKActionPerformed(java.awt.event.ActionEvent evt) {                                         
            // TODO add your handling code here:
            int i;
            for (i = 0; i < logins.length; i++)
            {
                
                if (text_login.getText().equalsIgnoreCase(logins[i]))
                {
                    
                    if (!text_password.getText().equalsIgnoreCase(passwd[i]))
                    {
                        System.out.println(text_password.getText());
                        System.out.println(passwd[i]);
                        JOptionPane.showMessageDialog(null, "Invalid password", "Dialog Message", JOptionPane.ERROR_MESSAGE);
                        text_password.setText("");
                        break;
    
                    }
                    else
                    {
                        this.dispose();
                        System.out.println("3");
                        Shrimp shrimp = new Shrimp();
                        break;
                    }
                }
    
            }
            if (i == logins.length)
            {
                JOptionPane.showMessageDialog(null, "Invalid login", "Dialog Message", JOptionPane.ERROR_MESSAGE);
                text_login.setText("");
    
            }
    }                                        
    
        private void buttonCancelActionPerformed(java.awt.event.ActionEvent evt) {                                             
            // TODO add your handling code here:
            this.setVisible(false);
            System.exit(0);
    }                                            
    
        /**
        * @param args the command line arguments
        */
        public static void main(String args[])
        {
            java.awt.EventQueue.invokeLater(new Runnable()
            {
                public void run()
                {
                    Authentifier aut=new Authentifier();
                    aut.setVisible(true);
                    aut.setLocationRelativeTo(null);
    //                new Menu().setVisible(true);
    //                new EDD.FrameEDD(null, "commerce").setVisible(true);
    //               new REQUIREMENT.FrameNewRequirement("walid").setVisible(true);
    //                new REQUIREMENT.FrameOldRequirement("ccc.xml").setVisible(true);
                }
            });
        }
    
        // Variables declaration - do not modify                     
        private javax.swing.JButton buttonCancel;
        private javax.swing.JButton buttonOK;
        private javax.swing.JLabel label_login;
        private javax.swing.JLabel label_pwd;
        private javax.swing.JPanel panel_authent;
        private javax.swing.JTextField text_login;
        private javax.swing.JPasswordField text_password;
        // End of variables declaration                   
    
    }
    if i call another class, not shrimp, it run correctly and show it

Similar Threads

  1. Replies: 3
    Last Post: 05-08-2012, 06:26 PM
  2. Replies: 0
    Last Post: 04-08-2011, 10:46 AM
  3. Replies: 1
    Last Post: 03-10-2010, 02:53 PM
  4. Replies: 1
    Last Post: 12-05-2009, 08:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •