Help pls

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Apr 2007
Posts: 5
Reputation: kapkan is an unknown quantity at this point 
Solved Threads: 0
kapkan's Avatar
kapkan kapkan is offline Offline
Newbie Poster

Help pls

 
0
  #1
Apr 9th, 2007
Help me pls. I have some problems with method getClient(), bring only two classes.
  1. package drugstore;
  2.  
  3. public class DrugstoreFrame extends JFrame {
  4. Client person;
  5. ...
  6.  
  7. public Client getClient(){
  8. person.setAccount(getField(jTextField4));
  9. person.setPassword(getField(jPasswordField2));
  10. person.setFio(getField(jTextField5));
  11. person.setAddress(getField(jTextField6));
  12. person.setTelephone(getField(jTextField3));
  13. person.setAdditionalInformation(getField(jTextField7));
  14. return person;
  15. }
  16. private String getField(JTextField field){
  17. return field.getText();
  18. }
  19. public void jButton10_mouseClicked(MouseEvent e) {
  20. person = getClient();
  21. try{
  22. database.newPerson(person);
  23. }catch(DataAccessException exception){
  24. }
  25. }
  26. }


  1. package drugstore;
  2.  
  3. public class Client {
  4. private String fio = "";
  5. private String address = "";
  6. private String telephone = "";
  7. private String additional_information = "";
  8. private String account = "";
  9. private String password = "";
  10. private int client_id;
  11.  
  12. Client(int client_id){
  13. this.client_id = client_id;
  14.  
  15. }
  16.  
  17. public void setClientId(int client_id){
  18. this.client_id = client_id;
  19. }
  20. public void setFio(String fio){
  21. this.fio = fio;
  22. }
  23. public void setAddress(String address){
  24. this.address = address;
  25. }
  26. public void setTelephone(String telephone){
  27. this.telephone = telephone;
  28. }
  29. public void setAdditionalInformation(String additional_information){
  30. this.additional_information = additional_information;
  31. }
  32. public void setAccount(String account){
  33. this.account = account;
  34. }
  35. public void setPassword(String password){
  36. this.password = password;
  37. }
  38. }

When performing the program we receive necessary error.


  1. Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
  2. at drugstore.DrugstoreFrame.getClient(DrugstoreFrame.java:293)
  3. at drugstore.DrugstoreFrame.jButton10_mouseClicked(DrugstoreFrame.java:389)
  4. at drugstore.DrugstoreFrame_jButton10_mouseAdapter.mouseClicked(DrugstoreFrame.java:409)
  5. at java.awt.AWTEventMulticaster.mouseClicked(AWTEventMulticaster.java:212)
  6. at java.awt.Component.processMouseEvent(Component.java:5491)
  7. at javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
  8. at java.awt.Component.processEvent(Component.java:5253)
  9. at java.awt.Container.processEvent(Container.java:1966)
  10. at java.awt.Component.dispatchEventImpl(Component.java:3955)
  11. at java.awt.Container.dispatchEventImpl(Container.java:2024)
  12. at java.awt.Component.dispatchEvent(Component.java:3803)
  13. at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
  14. at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3901)
  15. at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
  16. at java.awt.Container.dispatchEventImpl(Container.java:2010)
  17. at java.awt.Window.dispatchEventImpl(Window.java:1774)
  18. at java.awt.Component.dispatchEvent(Component.java:3803)
  19. at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
  20. at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:242)
  21. at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
  22. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
  23. at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
  24. at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
Last edited by kapkan; Apr 9th, 2007 at 2:09 pm. Reason: bad title, sorry =)
Reply With Quote Quick reply to this message  
Join Date: Apr 2007
Posts: 5
Reputation: kapkan is an unknown quantity at this point 
Solved Threads: 0
kapkan's Avatar
kapkan kapkan is offline Offline
Newbie Poster

Re: Help pls

 
0
  #2
Apr 10th, 2007
I have found the problem.
public Client getClient(){
person = new Client();
...
}
Last edited by kapkan; Apr 10th, 2007 at 5:41 am.
Reply With Quote Quick reply to this message  
Join Date: Dec 2004
Posts: 4,249
Reputation: peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of peter_budo has much to be proud of 
Solved Threads: 492
Moderator
Featured Poster
peter_budo's Avatar
peter_budo peter_budo is offline Offline
Code tags enforcer

Re: Help pls

 
0
  #3
Apr 10th, 2007
Nicely done, we would be able to help you as that wasn't part of the code and rest which you provided does look fine
Learn to see in another's calamity the ills which you should avoid.
Publilius Syrus
(~100 BC)

LJC - London Java Community, Graduate & Undergraduate Software Development Community, JAVAWUG (Java Web User Group), The London Android Group
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC