troubleshooting Question

help me out ! friends

Avatar of Manaswi11
Manaswi11 asked on
7 Comments1 Solution205 ViewsLast Modified:
  I am trying to make a program ,In which frame asks for login passwd if you put correct login passwd, dialogbox
will be pop up containg your records(yourscore,city,etc).
plz check it out and make it runnable

// Student Record
    //Enter Login passwd and get your record
import java.awt.*;
import java.awt.event.*;
import java.applet.*;

 public class StudRecord extends Dialog implements ActionListener   {
       // create information about students
       private String[] namel = {"Manaswi","Sawan","Rahul","Nitish","Shailesh",
       private String[] hint = {"A","B","C","D","E","F"};
       private String[] city = {"Delhi","Patna","Lucknow","Chennai","Kolkata","Mumbai"};

       private String[] title = {"Sharma","Gupta","Sinha","Ranjan","Singh","Swami"};
       private String[] password = {"Sharma","Gupta","Sinha","Ranjan","Singh","Swami"};
       private float[] age = {20,19,20,21,18,18};
       private float[] score = {80,79,70,51,78,48};
       private LogonDialog logonDialog;    //use dialog window for input
       private TextField fullName;
       private TextField cityA;
       private TextField ageA;
       private TextField scoreA;

     //constructor of StudRecord
        public StudRecord()          {
           // super.setTitle("Find Your Details");
          //display full name
           Panel p1 = new Panel();
           p1.setLayout(new FlowLayout(FlowLayout.LEFT));
           p1.add(new Label("Name"));
           p1.add(fullName = new TextField(5));
         //display age
             Panel p2 = new Panel();
           p2.setLayout(new FlowLayout(FlowLayout.LEFT));
           p2.add(new Label("Age"));
           p2.add(ageA = new TextField(5));
         //display city

           Panel p3 = new Panel();
           p3.setLayout(new FlowLayout(FlowLayout.LEFT));
           p3.add(new Label("City"));
           p3.add(cityA = new TextField(5));

         //display score
             Panel p4 = new Panel();
           p4.setLayout(new FlowLayout(FlowLayout.LEFT));
           p4.add(new Label("Score"));
           p4.add(scoreA = new TextField(5));
           //place panels in the frame

         //create a dialog window

            logonDialog = new LogonDialog(this,"Login and Enter",true);
          }  //Constructor ends
            /* find the username and password then return the index
                if found otherwise return -1   */

           public int find(String username,String pw)  {
                  for(int i= 0; i<namel.length; i++)  
                     if(namel[i].equals(username) && password[i].equals(pw))
                             return i;
                            return -1;

           //display student name age city and score after getting index
          public void view(int index)         {
            fullName.setText(namel[index] +" " + title[index]);


         class LogonDialog extends Applet    {
             Frame f ;
             public void init()   {
           private TextField namelLD,passwordLD ;   //for user input
           private Button okBt;                  //submit user input
           private Label label;                 //display logon status
           private StudRecord parentFrame;  

             //Constructor of LogonDialog
          public LogonDialog(parentFrame,String title,boolean  modal) {
            parentFrame = (StudRecord)parent;

           //create input section
              Panel p1 = new Panel();
             p1.setLayout(new FlowLayout(FlowLayout.LEFT));
             p1.add(new Label("Enter username and password"));
               Panel p2 = new Panel();
              p2.setLayout(new GridLayout());
              p2.add(new Label("User Name"));
              p2.add(namelLD = new TextField(10));
              p2.add(new Label("Password"));
              p2.add(passwordLD = new TextField(10));

        //set the echo characterr for password
        //place p1,p2 and button
              setLayout(new BorderLayout());
              okBt = new Button("OK");
           //register listener

           //initialize this dialog to its prefered size
           }  //Constructor ends

       //respond to the button
           public void actionPerformed(ActionEvent ae)  
                String str = ae.getActionCommand();
               //  if(ae.getSource() instanceOf Button)
                                     int index = parentFrame.find(namelLD.getText().trim(),
                                    // passwordLD.getText().trim();
                                       if(index == -1) {
                                                             label.setText("Invalid user name and password");

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 7 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 7 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros