1 2 3 Previous Next 33 Replies Latest reply: Mar 9, 2013 9:34 PM by EJP Go to original post RSS
      • 15. Re: Hash Mapping
        995566
        hi, thanks for your message

        The easiest thing to do is paste the whole code up
        public class StaticMap 
        {
             
                
              static Person currentEntry;
                static DoctorQueries doctorQueries;
                static List<Person> results; 
                 static int numberOfEntries = 0;
              static int currentEntryIndex;
               
              
                  private   final static JTextField textField_PatientID= StaticMap.TextField_PatientId;
        
                  private  static  final JTextField textField_FirstName= null;
        
                  private  static  final JTextField textField_LastName= null;
        
                  private  static  final JTextField textField_Address= null;
        
                  private  static  final  JTextField textField_Number= null;
        
                  private  static    JButton    nextButton;
                  private  static    JButton    previousButton;
                  
        
                  private  static  final JTextField textField_Query=null;
        
                  private  static  final JTextField indexTextField= null;
        
                  private  static  final JTextField maxTextField= null;
        
                  private  static  final JTextField TextField_PatientId = null;
                     private  static  final JTextField textField_date= null;
        
                     private  static  final JTextField textField_illness= null;
        
                     
                     
                     
                    
               
        
        
                
                
        
                
             public  static Map <String, ActionListener> listener = new HashMap <String, ActionListener> ();
             
              
             static 
             {
                  
                  doctorQueries = new DoctorQueries();
                  
                  
                  
               listener.put("QUERY", new ActionListener() {
        
        
                  
                   public void actionPerformed(ActionEvent e) 
                  {
                        queryButtonActionPerformed( e );
                  }
               });
             
               
                  
               listener.put("PREVIOUS", new ActionListener() {
        
                  @Override
                  
                  public void actionPerformed(ActionEvent e) 
                  {
                       previousButtonActionPerformed( e );
                  }
               });
               
               
               listener.put("NEXT", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            nextButtonActionPerformed( e );
                       }
                    });
                    
               
               
               listener.put("CONNECT", new ActionListener() {
        
                       public  void actionPerformed(ActionEvent e) 
                       {
                             ConnectButtonActionPerformed( e );
                       }
                    });
               
               
               
               listener.put("DELETE", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            DeleteButtonActionPerformed( e );
                       }
                    });
               
               listener.put("INSERT", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            insertButtonActionPerformed( e );
                       }
                    });
               
               listener.put("EDIT", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            EditButtonActionPerformed( e );
                       }
                    });
               
               listener.put("INSERTPATIENTHISTORY", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            AddPatientHistoryButtonActionPerformed( e );
                       }
                    });
               
               listener.put("NEWJFRAME", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            NEWFRAMEactionPerformed( e );
                       }
                    });
               
               listener.put("ABOUTFRAME", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            ABOUTFRAMEactionPerformed( e );
                       }
                    });
               
               listener.put("EXIT", new ActionListener() {
        
                       @Override
                       
                       public void actionPerformed(ActionEvent e) 
                       {
                            EXITactionPerformed( e );
                       }
                    });
               
             }
              
             public static Map <String, JTextField> text = new HashMap <String, JTextField> ();
             {
                  text.put("ID", textField_PatientID);
                    text.put("first", textField_FirstName);
                    text.put("last", textField_LastName);
                    text.put("add", textField_Address);
                    text.put("number", textField_Number);
                    text.put("query", textField_Query);
                    text.put("index", indexTextField);
                    text.put("patientid", TextField_PatientId);
                    text.put("date", textField_date);
                    text.put("illness", textField_illness);
                  
             }
             
                private static  void nextButtonActionPerformed( ActionEvent evt ) 
                {
                        currentEntryIndex++;
                        
                        if ( currentEntryIndex >= numberOfEntries )
                           currentEntryIndex = 0;
                        
                        indexTextField.setText( " " + ( currentEntryIndex + 1 ) );
                        indexTextFieldActionPerformed( evt );
                     } // end method nextButtonActionPerformed
        
                
                
                /**
                 * handles call when queryButton is clicked
                 * @param evt
                 */
                
                
                
                
             
        
                
                
             
                /**
                 * handles call when browseButton is clicked
                 * @param evt
                 */
                
                public static void ConnectButtonActionPerformed( ActionEvent e )
                {
                     
                        
                
                        try
                        {
                           results = doctorQueries.getAllPeople();
                      
                           
                              
                          numberOfEntries = results.size();
                        
                       
                           if ( numberOfEntries != 0 )
                           {
                              currentEntryIndex = 0;
                              currentEntry = results.get( currentEntryIndex );
                             textField_PatientID.setText("" + currentEntry.getsID() );
                               textField_FirstName.setText( currentEntry.getFirstName() );
                               textField_LastName.setText( currentEntry.getLastName() );
                                textField_Address.setText( currentEntry.getAddress() );
                              textField_Number.setText( currentEntry.getPhoneNumber() );
                              maxTextField.setText( "" + numberOfEntries );
                           indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                             nextButton.setEnabled( true );
                            previousButton.setEnabled( true ); 
                           
                           } // end if 
                         
                        } // end try
                        catch ( Exception e1 )
                        {
                           e1.printStackTrace();
                        } // end catch
                       
                     } // end method browseButtonActionPerformed
                
                
                public static void NEWFRAMEactionPerformed(ActionEvent evt) 
                   {
                     DoctorsRecordDisplay doctor= new DoctorsRecordDisplay(); // Creating the About Page
                        //doctor.setSize(new Dimension(500,300)); //Setting Size for Dialog
                        doctor.setLocation(200, 50); // Setting up the Startup Location
                        doctor.setVisible(true); // Setting Visible to True
                        
                   }
                
                public static   void ABOUTFRAMEactionPerformed(ActionEvent evt) 
                   {
                        About about= new About(); // Creating the About Page
                        about.setSize(new Dimension(500,300)); //Setting Size for Dialog
                        about.setLocation(300, 50); // Setting up the Startup Location
                         about.setVisible(true); // Setting Visible to True
                         
                   }
             
                public static  void EXITactionPerformed(ActionEvent evt) 
                   {
                        System.exit(0); // Kills to Program Once Exit is Clicked On. 
                         
                   }
                
                public static  void queryButtonActionPerformed( ActionEvent evt )
                {
                  
                
             
                results = 
                    doctorQueries.getPeopleByLastName( textField_Query.getText() );
                numberOfEntries = results.size();
                
                if ( numberOfEntries != 0 )
                {
                   currentEntryIndex = 0;
                   currentEntry = results.get( currentEntryIndex );
                   textField_PatientID.setText("" + currentEntry.getsID() );
                   textField_FirstName.setText( currentEntry.getFirstName() );
                   textField_LastName.setText( currentEntry.getLastName() );
                   textField_Address.setText( currentEntry.getAddress() );
                   textField_Number.setText( currentEntry.getPhoneNumber() );
                   maxTextField.setText( "" + numberOfEntries );
                   indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                   nextButton.setEnabled( true );
                   previousButton.setEnabled( true );
              
                } // end if
                
                else
                   ConnectButtonActionPerformed( evt );
             } // end method queryButtonActionPerformed
                
        }
        This is how is from my main class
             /*
                   * Setting up the Connection Button.
                   */
                  ConnectButton.setText("Connect to Database"); //Setting Text to ConnectButton
                  ConnectButton.setEnabled(true); //Setting Enabled to True 
                  ConnectButton.addActionListener(StaticMap.listener.get("CONNECT")); //Getting ActionListener From JavaClass StaticMap 
                  navigatePanel.add(ConnectButton); // Adding ConnectButton to NavigatePanel
                  
        • 16. Re: Hash Mapping
          J2EE_Life
          And Error stack trace? That's also required in order understand the real problem
          • 17. Re: Hash Mapping
            995566
            Heres the Errors showing on the Console


            java.lang.NullPointerException
                 at StaticMap.ConnectButtonActionPerformed(StaticMap.java:319) - > Pointing at textField_PatientID.setText("" + currentEntry.getsID() );
                 at StaticMap$4.actionPerformed(StaticMap.java:123) --> Pointing at ConnectButtonActionPerformed( e );
                 at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
                 at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
                 at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
                 at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
                 at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
                 at java.awt.Component.processMouseEvent(Component.java:6505)
                 at javax.swing.JComponent.processMouseEvent(JComponent.java:3321)
                 at java.awt.Component.processEvent(Component.java:6270)
                 at java.awt.Container.processEvent(Container.java:2229)
                 at java.awt.Component.dispatchEventImpl(Component.java:4861)
                 at java.awt.Container.dispatchEventImpl(Container.java:2287)
                 at java.awt.Component.dispatchEvent(Component.java:4687)
                 at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4832)
                 at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4492)
                 at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4422)
                 at java.awt.Container.dispatchEventImpl(Container.java:2273)
                 at java.awt.Window.dispatchEventImpl(Window.java:2719)
                 at java.awt.Component.dispatchEvent(Component.java:4687)
                 at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:723)
                 at java.awt.EventQueue.access$200(EventQueue.java:103)
                 at java.awt.EventQueue$3.run(EventQueue.java:682)
                 at java.awt.EventQueue$3.run(EventQueue.java:680)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
                 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:87)
                 at java.awt.EventQueue$4.run(EventQueue.java:696)
                 at java.awt.EventQueue$4.run(EventQueue.java:694)
                 at java.security.AccessController.doPrivileged(Native Method)
                 at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
                 at java.awt.EventQueue.dispatchEvent(EventQueue.java:693)
                 at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
                 at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
                 at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
                 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
                 at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
                 at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)



            When i Initialize the Text Fields and the Buttons inside the Static Map
                 
                      textField_PatientID = new JTextField();
                      textField_FirstName = new JTextField();
                      textField_LastName = new JTextField();
                      textField_Address = new JTextField();
                      textField_Number = new JTextField();
                      textField_Query = new JTextField();
                      indexTextField = new JTextField();
                      maxTextField = new JTextField();
                      TextField_PatientId = new JTextField();
                      textField_date = new JTextField();
                      textField_illness = new JTextField();
                 
                      nextButton = new JButton();
                      previousButton = new JButton();
                      
            And run the Program and click on Connect nothing Happens.. No Error or nothing..
            Edited by: 992563 on Mar 9, 2013 10:12 AM

            Edited by: 992563 on Mar 9, 2013 10:17 AM
            • 18. Re: Hash Mapping
              J2EE_Life
              textField_PatientID = new JTextField();
              Above initialization doesn't exist anywhere in your code that you pasted.
              private final static JTextField textField_PatientID= StaticMap.TextField_PatientId;
              private static final JTextField TextField_PatientId = null;
              Your above piece of code contains two variables textField_PatientID and textField_PatientId ---> Just case of last 'd' in the name. Though this is quite unnecessary to define two in this case.
              Anyway both are initialized to null in this case.
              public static Map <String, JTextField> text = new HashMap <String, JTextField> ();
                   {
                        text.put("ID", textField_PatientID);
                          text.put("first", textField_FirstName);
                          text.put("last", textField_LastName);
                          text.put("add", textField_Address);
                          text.put("number", textField_Number);
                          text.put("query", textField_Query);
                          text.put("index", indexTextField);
                          text.put("patientid", TextField_PatientId);
                          text.put("date", textField_date);
                          text.put("illness", textField_illness);
                        
                   }
              Do you realize above is not a method definition but a variable initialization followed by a block of code. Is it intentional or by mistake?
              • 19. Re: Hash Mapping
                995566
                I have two patient text fields one for person table and the other history


                I took away the final, and I tried initialization to the text fields
                It seem to remove the errors just now finding a way to get the outter class to settext to the inner class text fields
                • 20. Re: Hash Mapping
                  J2EE_Life
                  It seem to remove the errors
                  So that means my suggestions were helpful. Lets hold on this.
                  now finding a way to get the outter class to settext to the inner class text fields
                  I think by outer class you mean StaticMap , what inner class means?
                  • 21. Re: Hash Mapping
                    995566
                    Well when I say inner class what I meant was my

                    Main class display records
                    • 22. Re: Hash Mapping
                      J2EE_Life
                      I am not sure what you mean... But if you mean setting mapping as below:
                      text.put("patientid", TextField_PatientId);
                      You need to make sure that textfield is not null.
                      • 23. Re: Hash Mapping
                        995566
                        I place the pointer to the Doctors Record Display hoping that it would Set Text to That Text Field inside the Doctors Record Display Frame.

                        Good Sign its not given me Errors, Am i better off to have my Action Listeners place back into Display Frame as Inner classes ?
                        or what i am trying to get then Good practice
                        public class StaticMap 
                        {
                             
                                
                              static Person currentEntry;
                                static DoctorQueries doctorQueries;
                                static List<Person> results; 
                                 static int numberOfEntries = 0;
                              static int currentEntryIndex;
                               
                                  
                                final static JTextField textField_PatientID = DoctorsRecordDisplay.textField_PatientID;
                                final static JTextField textField_FirstName = DoctorsRecordDisplay.textField_FirstName;
                                final static JTextField textField_LastName =  DoctorsRecordDisplay.textField_LastName;
                                final static JTextField textField_Address = DoctorsRecordDisplay.textField_Address;
                                final static JTextField     textField_Number =  DoctorsRecordDisplay.textField_Number;
                                  final static JTextField     textField_Query =  DoctorsRecordDisplay.textField_Query;
                                  final static JTextField     indexTextField =  DoctorsRecordDisplay.indexTextField;
                                  final static JTextField     maxTextField =  DoctorsRecordDisplay.maxTextField;
                                  final static JTextField     TextField_PatientId = DoctorsRecordDisplay.textField_PatientId;
                                  final static JTextField     textField_date = DoctorsRecordDisplay.textField_date;
                                  final static JTextField     textField_illness = DoctorsRecordDisplay.textField_illness;
                             
                                  static JButton          nextButton = new JButton();
                                  static JButton          previousButton = new JButton();
                                  
                             public  static Map <String, ActionListener> listener = new HashMap <String, ActionListener> ();
                             
                              
                             static 
                             {
                                  
                             
                                  
                             
                             
                                  nextButton = new JButton();
                                  previousButton = new JButton();
                                  
                                  
                                  
                                  doctorQueries = new DoctorQueries();
                                  
                                  
                                  
                               listener.put("QUERY", new ActionListener() {
                        
                        
                                  
                                   public void actionPerformed(ActionEvent e) 
                                  {
                                        queryButtonActionPerformed( e );
                                  }
                               });
                             
                               
                                  
                               listener.put("PREVIOUS", new ActionListener() {
                        
                                  @Override
                                  
                                  public void actionPerformed(ActionEvent e) 
                                  {
                                       previousButtonActionPerformed( e );
                                  }
                               });
                               
                               
                               listener.put("NEXT", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            nextButtonActionPerformed( e );
                                       }
                                    });
                                    
                               
                               
                               listener.put("CONNECT", new ActionListener() {
                        
                                       public  void actionPerformed(ActionEvent e) 
                                       {
                                             ConnectButtonActionPerformed( e );
                                       }
                                    });
                               
                               
                               
                               listener.put("DELETE", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            DeleteButtonActionPerformed( e );
                                       }
                                    });
                               
                               listener.put("INSERT", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            insertButtonActionPerformed( e );
                                       }
                                    });
                               
                               listener.put("EDIT", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            EditButtonActionPerformed( e );
                                       }
                                    });
                               
                               listener.put("INSERTPATIENTHISTORY", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            AddPatientHistoryButtonActionPerformed( e );
                                       }
                                    });
                               
                               listener.put("NEWJFRAME", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            NEWFRAMEactionPerformed( e );
                                       }
                                    });
                               
                               listener.put("ABOUTFRAME", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            ABOUTFRAMEactionPerformed( e );
                                       }
                                    });
                               
                               listener.put("EXIT", new ActionListener() {
                        
                                       @Override
                                       
                                       public void actionPerformed(ActionEvent e) 
                                       {
                                            EXITactionPerformed( e );
                                       }
                                    });
                               
                             }
                          
                        
                                  
                        
                        
                        
                              /*
                               * 
                               * This is Section is Storing all the 
                               *  private static void ButtonActions. 
                               *  
                               *  
                               */
                             
                             /**
                              * handles call when previousButton is clicked
                              * @param evt
                              */
                             
                             private static  void previousButtonActionPerformed( ActionEvent evt )
                             {
                                   currentEntryIndex--;
                                   
                                   if ( currentEntryIndex < 0 )
                                      currentEntryIndex = numberOfEntries - 1;
                                   
                                   indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                                   indexTextFieldActionPerformed( evt );  
                                } // end method previousButtonActionPerformed
                        
                                /**
                                 *  handles call when nextButton is clicked
                                 * @param evt
                                 */
                             
                                private static  void nextButtonActionPerformed( ActionEvent evt ) 
                                {
                                        currentEntryIndex++;
                                        
                                        if ( currentEntryIndex >= numberOfEntries )
                                           currentEntryIndex = 0;
                                        
                                        indexTextField.setText( " " + ( currentEntryIndex + 1 ) );
                                        indexTextFieldActionPerformed( evt );
                                     } // end method nextButtonActionPerformed
                        
                                
                                
                                /**
                                 * handles call when queryButton is clicked
                                 * @param evt
                                 */
                                
                                
                                
                                
                             
                        
                                
                                
                                /**
                                 *  handles call when a new value is entered in indexTextField
                                 * @param evt
                                 */
                                
                                public  static void indexTextFieldActionPerformed( ActionEvent e )
                                {
                                currentEntryIndex = 
                                 ( Integer.parseInt( indexTextField.getText() ) - 1 );
                              
                              if ( numberOfEntries != 0 && currentEntryIndex < numberOfEntries )
                              {
                                 currentEntry = results.get( currentEntryIndex );
                                 textField_PatientID.setText("" + currentEntry.getsID() );
                                 textField_FirstName.setText( currentEntry.getFirstName() );
                                 textField_LastName.setText( currentEntry.getLastName() );
                                 textField_Address.setText( currentEntry.getAddress() );
                                 textField_Number.setText( currentEntry.getPhoneNumber() );
                                 maxTextField.setText( "" + numberOfEntries );
                                 indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                              } // end if
                            } // end method indexTextFieldActionPerformed
                                
                                
                                /**
                                 * handles call when browseButton is clicked
                                 * @param evt
                                 */
                                
                                public static void ConnectButtonActionPerformed( ActionEvent e )
                                {
                                     
                                        
                                
                                        try
                                        {
                                           results = doctorQueries.getAllPeople();
                                      
                                           
                                              
                                          numberOfEntries = results.size();
                                        
                                       
                                           if ( numberOfEntries != 0 )
                                           {
                                              currentEntryIndex = 0;
                                              currentEntry = results.get( currentEntryIndex );
                                             textField_PatientID.setText("" + currentEntry.getsID() );
                                               textField_FirstName.setText( currentEntry.getFirstName() );
                                               textField_LastName.setText( currentEntry.getLastName() );
                                                textField_Address.setText( currentEntry.getAddress() );
                                              textField_Number.setText( currentEntry.getPhoneNumber() );
                                              maxTextField.setText( "" + numberOfEntries );
                                           indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                                             nextButton.setEnabled( true );
                                            previousButton.setEnabled( true ); 
                                           
                                           } // end if 
                                         
                                        } // end try
                                        catch ( Exception e1 )
                                        {
                                           e1.printStackTrace();
                                        } // end catch
                                       
                                     } // end method browseButtonActionPerformed
                                
                              
                                
                                /**
                                 * handles call when DeleterButton is clicked
                                 * @param evt
                                 */
                                
                                 public static void DeleteButtonActionPerformed(ActionEvent evt)
                                {
                                     int result = doctorQueries.removePerson( 
                                                    textField_PatientID.getText());
                                     
                                                 if ( result > 0 )
                                                         JOptionPane.showMessageDialog(null, "Person Removed!" ,
                                                              "Person Removed", JOptionPane.PLAIN_MESSAGE);
                                                        else
                                                           JOptionPane.showMessageDialog(null,"Person not Removed!",
                                                              "Error", JOptionPane.PLAIN_MESSAGE );
                                                 
                                                        ConnectButtonActionPerformed( evt );
                                                     } // end method insertButtonActionPerformed
                                
                                
                                /**
                                 * handles call when insertButton is clicked
                                 * @param evt
                                 */
                                
                                public static  void insertButtonActionPerformed( ActionEvent evt ) 
                                {
                                        int result = doctorQueries.addPerson(  textField_FirstName.getText(),
                                                  textField_LastName.getText(), textField_Address.getText(),
                                                  textField_Number.getText() );
                                        
                                        if ( result == 1 )
                                         JOptionPane.showInputDialog(
                                              null, new String[] {
                                                  "Person added!",
                                                  "First Name: [" +
                                                            textField_FirstName.getText() + "]",
                                                  "Last Name: [" +
                                                            textField_LastName.getText() + "]",
                                                  "Address: [" +
                                                            textField_Address.getText() + "]",
                                                  "Phone Number: [" +
                                                            textField_Number.getText() + "]"
                                              }
                                          );
                                        else
                                           JOptionPane.showInternalMessageDialog( null, "Person not added!",
                                              "Error", JOptionPane.PLAIN_MESSAGE );
                                            
                                        ConnectButtonActionPerformed( evt );
                                     } // end method insertButtonActionPerformed
                                
                                
                                /**
                                 * handles call when EditButton is clicked
                                 * @param evt
                                 */
                                
                                private  static void EditButtonActionPerformed( ActionEvent evt ) 
                                {
                                        int result = doctorQueries.EditPerson( textField_PatientID.getText(), textField_FirstName.getText(),
                                                  textField_LastName.getText(), textField_Address.getText(),
                                                  textField_Number.getText() );
                                        if ( result == 1 )
                                         JOptionPane.showInputDialog(
                                              null, new String[] {
                                                  "Person Updated New Details!",
                                                  "First Name: [" +
                                                            textField_FirstName.getText() + "]",
                                                  "Last Name: [" +
                                                            textField_LastName.getText() + "]",
                                                  "Address: [" +
                                                            textField_Address.getText() + "]",
                                                  "Phone Number: [" +
                                                            textField_Number.getText() + "]"
                                              }
                                          );
                                        else
                                           JOptionPane.showMessageDialog( null, "Person not Updated!",
                                              "Error", JOptionPane.PLAIN_MESSAGE );
                                            
                                        ConnectButtonActionPerformed( evt );
                                     } // end method insertButtonActionPerformed
                                     
                                
                                /**
                                 * handles call when AddPatientHistory is clicked
                                 * @param evt
                                 */
                                
                                private static  void AddPatientHistoryButtonActionPerformed ( ActionEvent evt ) 
                                {
                                     int result1 = doctorQueries.addHistory(  TextField_PatientId.getText(),
                                               textField_date.getText(), textField_illness.getText()
                                                   );
                                        if ( result1 == 1 )
                                         JOptionPane.showInputDialog(
                                              null, new String[] {
                                                  "Patient History Added!",
                                                  "Patient ID: [" +
                                                            TextField_PatientId.getText() + "]",
                                                  "Date: [" +
                                                            textField_date.getText() + "]",
                                                  "Illness: [" +
                                                            textField_Address.getText() + "]"
                                              }
                                          );
                                        
                                  
                                        else
                                           JOptionPane.showMessageDialog( null, "Person History not added!",
                                              "Error", JOptionPane.PLAIN_MESSAGE );
                                            
                                        ConnectButtonActionPerformed( evt );
                        
                                     
                                } // end method AddPatientHistoryButtonActionPerformed
                                
                                
                                
                                public static void NEWFRAMEactionPerformed(ActionEvent evt) 
                                   {
                                     DoctorsRecordDisplay doctor= new DoctorsRecordDisplay(); // Creating the About Page
                                        //doctor.setSize(new Dimension(500,300)); //Setting Size for Dialog
                                        doctor.setLocation(200, 50); // Setting up the Startup Location
                                        doctor.setVisible(true); // Setting Visible to True
                                        
                                   }
                                
                                public static   void ABOUTFRAMEactionPerformed(ActionEvent evt) 
                                   {
                                        About about= new About(); // Creating the About Page
                                        about.setSize(new Dimension(500,300)); //Setting Size for Dialog
                                        about.setLocation(300, 50); // Setting up the Startup Location
                                         about.setVisible(true); // Setting Visible to True
                                         
                                   }
                             
                                public static  void EXITactionPerformed(ActionEvent evt) 
                                   {
                                        System.exit(0); // Kills to Program Once Exit is Clicked On. 
                                         
                                   }
                                
                                public static  void queryButtonActionPerformed( ActionEvent evt )
                                {
                                  
                                
                             
                                results = 
                                    doctorQueries.getPeopleByLastName( textField_Query.getText() );
                                numberOfEntries = results.size();
                                
                                if ( numberOfEntries != 0 )
                                {
                                   currentEntryIndex = 0;
                                   currentEntry = results.get( currentEntryIndex );
                                   textField_PatientID.setText("" + currentEntry.getsID() );
                                   textField_FirstName.setText( currentEntry.getFirstName() );
                                   textField_LastName.setText( currentEntry.getLastName() );
                                   textField_Address.setText( currentEntry.getAddress() );
                                   textField_Number.setText( currentEntry.getPhoneNumber() );
                                   maxTextField.setText( "" + numberOfEntries );
                                   indexTextField.setText( "" + ( currentEntryIndex + 1 ) );
                                   nextButton.setEnabled( true );
                                   previousButton.setEnabled( true );
                              
                                } // end if
                                
                                else
                                   ConnectButtonActionPerformed( evt );
                             } // end method queryButtonActionPerformed
                                
                        }
                        
                                     
                             
                             
                        • 24. Re: Hash Mapping
                          J2EE_Life
                          Ahhh, Now the code is again changed...
                          final static JTextField     TextField_PatientId = DoctorsRecordDisplay.textField_PatientId;
                          Here are you sure in class DoctorsRecordDisplay, textField_PatientId is not initialized to null???

                          As I see you instantiate DoctorsRecordDisplay in below method, which contains nothing about textField_PatientId, and I think its either not initialized or initialized to null.
                          public static void NEWFRAMEactionPerformed(ActionEvent evt) 
                                     {
                                       DoctorsRecordDisplay doctor= new DoctorsRecordDisplay(); // Creating the About Page
                                          //doctor.setSize(new Dimension(500,300)); //Setting Size for Dialog
                                          doctor.setLocation(200, 50); // Setting up the Startup Location
                                          doctor.setVisible(true); // Setting Visible to True
                                          
                                     }
                          Edited by: J2EE_Life on Mar 9, 2013 4:28 PM
                          • 25. Re: Hash Mapping
                            995566
                            No my JText Fields are not set to Null in my Display Class.
                              static JTextField textField_PatientID; // = StaticMap.textField_PatientID;
                                                static  JTextField textField_FirstName; //= StaticMap.textField_FirstName;
                                                static  JTextField textField_LastName; // = StaticMap.textField_LastName;
                                                static  JTextField textField_Address; // = StaticMap.textField_Address;
                                                static  JTextField textField_Number; // = StaticMap.textField_Number;
                                                static  JTextField textField_Query; // = StaticMap.textField_Query;
                                                static  JTextField indexTextField; // = StaticMap.indexTextField;
                                                static  JTextField maxTextField; // = StaticMap.maxTextField;
                                                static JTextField textField_PatientId; // =  StaticMap.TextField_PatientId;
                                                 static JTextField     textField_date; // = StaticMap.textField_date;
                                                 static JTextField     textField_illness; // = StaticMap.textField_illness;
                                              
                                            
                                      
                                 
                                           private JButton  ConnectButton;
                                           private JButton    queryButton;
                                           private JButton    insertButton;
                                           private JButton    EditButton;
                                           private JButton    DeleteButton;
                                           
                                           private  static  JButton nextButton;
                                           private  static  JButton previousButton;
                                           
                                      
                            
                                      
                            
                                 
                                 
                                 
                                 
                                 
                                  //Create the frame.
                                 public DoctorsRecordDisplay() 
                                 {
                                      
                                 
                                      super( "Doctors Records" ); //Setting Title to GUI
                                      //doctorQueries = new DoctorQueries();
                                      setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Close the Program on Exit
                                      doctorQueries = new DoctorQueries();
                                      
                                      setBounds(100, 100, 1102, 543); //Setting Bounds to Frame
                                      
                                      contentPane = new JPanel(); //Creating ContentPane
                                      contentPane.setBorder(new EmptyBorder(5, 5, 5, 5)); //Setting up Border 
                                      contentPane.setLayout(new BorderLayout(0, 0)); // Setting up BorderLayout
                                      setContentPane(contentPane); //Add Content pane to JFrame
                                      
                                      JSplitPane splitPane = new JSplitPane(); //Creating SplitPane
                                      splitPane.setOrientation(JSplitPane.VERTICAL_SPLIT); //Setting the Split pane to a Vertical Split
                                      contentPane.add(splitPane, BorderLayout.CENTER); // Adding SplitPane to ContentPane 
                                      JSplitPane splitPane_1 = new JSplitPane(); // Creating SplitPane1
                                      
                                      splitPane.setLeftComponent(splitPane_1); // Setting SplitPane to the Left
                                      JPanel panelUser = new JPanel(); // Adding panelUser to J panel
                                      panelUser.setBorder(BorderFactory.createTitledBorder("Records")); // Setting Border and Tile to PanelUser
                                      splitPane_1.setRightComponent(panelUser); //Setting up panelUser to Right hand side of SplitPanel
                            
                                       previousButton = new JButton(); // Creating JButton Previous
                                        nextButton = new JButton(); // Creating JButton Previous
                                        ConnectButton = new JButton(); //Creating JButton Connection.
                                      
                                      
                            My NEWFRAMEactionPerformed(ActionEvent evt) is only a Method that Opens up a new JFrame of Display Records.. It Automatically takes the parameter of the Display Code as its own.. as im just reopening the Display Records in effect..
                            • 26. Re: Hash Mapping
                              J2EE_Life
                              If not null, what are they initialized to?

                              Edited by: J2EE_Life on Mar 9, 2013 4:28 PM
                              • 27. Re: Hash Mapping
                                995566
                                as for the static map they are initialized to Doctors Records

                                as for the Doctors Records they arent initialized to anything just have

                                textField_Query = new JTextField(); //Creating Text Field
                                          panelButtons.add(textField_Query, "4, 20, 4, 1"); // Adding Text Field to Panel
                                          textField_Query.setColumns(10); //Setting Size of Text Field Query
                                          panelButtons.add(queryButton, "14, 20");
                                • 28. Re: Hash Mapping
                                  J2EE_Life
                                  The context is getting blurred, and it is becoming difficult.. to track this textfields :(

                                  .
                                  • 29. Re: Hash Mapping
                                    995566
                                    if you look up, i did click on helpful..