Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9004289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:51:58+00:00 2026-06-16T00:51:58+00:00

i always end up with this error Exception in thread AWT-EventQueue-0 java.lang.NullPointerException when im

  • 0

i always end up with this error “Exception in thread “AWT-EventQueue-0″ java.lang.NullPointerException” when im running my program. i have Member Class where i code my setter and getter. All the entities i need id there. now i have another method in “Admin Class”

 public class Admin {
     private ArrayList<Member> members;
     private String AccessName;
     private String username;
     private String password;

     public Admin(){
        this.AccessName="Ms. April Santos";
        this.username = "estella";
        this.password = "teller";
        this.members = new ArrayList<Member>();
    }

    public ArrayList<Member> getMembers() {
        return members;
    }

    public void setMembers(ArrayList<Member> members) {
        this.members = members;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getAccessName() {
        return AccessName;
    }

    public void setAccessName(String AccessName) {
        this.AccessName=AccessName;;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final Admin other = (Admin) obj;
        if ((this.username == null) ? (other.username != null) : !this.username.equals(other.username)) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 7;
        hash = 97 * hash + (this.username != null ? this.username.hashCode() : 0);
        return hash;
    }

    @Override
    public String toString() {
        return "Admin{" + "members=" + members + ", AccessName;=" + AccessName + ", username=" + username + ", password=" + password + '}';
    }

       public Member searchMember(Member member){
        return this.searchMember(member.getMemberId());
    }

         public Member searchMember(String memberId){
          for(Member member : this.members){
            if(member.getMemberId().equals(memberId)){
                return member;
            }
          }
          return null;
    }

    public Member addMember(Member member){
        if (this.searchMember(member) == null){
            this.members.add(member);
            return member;
        }
        return null;
    }

    public Member addMember(String memberId, String firstName,String middleName, String lastName){
        if (this.searchMember(memberId) == null){
            Member member = new Member(memberId, firstName,middleName, lastName);
            this.members.add(member);
            return member;
        }
        return null;
    }

    public boolean validateLogin(String username, String password){
        boolean valid = false;
        valid = this.username.equals(username) && this.password.equals(password);
        return valid;
    }

   }

now im calling public addMember(String memberId, String firstName,String middleName, String lastName) in my AddMemberView(GUI). im trying to get all the text in the textfield/combobox and set it so that it will be temporary saved and ready to be saved in database as i code my DAO. this is my AddMemberView btnSave action look:

 import java.sql.SQLException;
 import java.text.*;
 import java.util.*;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 import javax.swing.JOptionPane;
 import rtu.tomis.bom.Admin;
 import rtu.tomis.bom.Member;
 import rtu.tomis.dao.MemberDao;

 public class AddMemberView extends javax.swing.JPanel {

 private MainFrameView mainFrameView;
 private Member member;
  private Admin admin;

  AddMemberView(Member memb, Admin admin){

    this.member= memb;
    this.admin= admin;

}

public AddMemberView() {
    initComponents();
}

  public AddMemberView(MainFrameView mf) {
    this.mainFrameView = mf;
    initComponents();
}

    public AddMemberView(Member m) {
    this.member = m;
    initComponents();
}

  private void btnSaveActionPerformed(java.awt.event.ActionEvent evt) {                                        
    String memberid = (this.txtMembersID.getText());
    String fname= (this.txtFirstName.getText());
    String mname=(this.txtMiddleName.getText());
    String lname=(this.txtLastName.getText());
    if(this.admin.addMember(memberid, fname,mname, lname) != null)//im having null here
    {
       try{
            member = this.admin.searchMember(memberid);// and if i remove that 1st line of null. the next null pointer is here
            String month = (String)cmbMonth.getSelectedItem();
            Integer day = (Integer) cmbDay.getSelectedItem();
            Integer year = (Integer)cmbYear.getSelectedItem();
            String bday = month + " " + day + ", " + year;
            DateFormat df = DateFormat.getDateInstance(DateFormat.MEDIUM, Locale.US);
            Date dateBday = df.parse(bday);
            String Block = this.txtBlkLotNo.getText();
            String Street = (String)this.cmbStreet.getSelectedItem();
            String Brgy=(String)this.cmbBarangay.getSelectedItem();
            String City= (String)this.cmbCity.getSelectedItem();
            String Address = Block + " " + "" + Street + " ," +  Brgy + " ," + City;
            String Full = fname + " " + mname + " " + lname;
            int age= Integer.parseInt(this.txtAge.getText());
            int contact = Integer.parseInt(this.txtContact.getText());
            String region =(String) this.cmbRegion.getSelectedItem();

            this.member.setFirstName(fname);// then if i remove the two my next null line is here and those who have this.**member**.setblabla.
            this.member.setMiddleName(mname);
            this.member.setLastName(lname);
            this.member.setFullname(Full);
            this.member.setLotNo(Block);
            this.member.setBarangay(Brgy);
            this.member.setCity(City);
            this.member.setFulladdress(Address);
            this.member.setBirthday(dateBday);
            this.member.setAge(age);
            this.member.setEmailAddress(this.txtEadd.getText());
            this.member.setVotersId(this.txtVotersID.getText());
            this.member.setContactNo(contact);
            this.member.setRegion(region);
            this.member.setMemberId(memberid);
           if(this.rbtnFemale != null){
               this.member.setGender(this.rbtnFemale.getLabel());
           }
               else{
               this.member.setGender(this.rbtnFemale.getLabel());
           }

       }catch (ParseException ex) {
            System.out.println("Exception: "+ ex.getMessage());
        }
        JOptionPane.showMessageDialog(this, "Info saved!");
        JOptionPane.showMessageDialog(this,"Name" + this.member.getFirstName());

    }

}                  

thanks for your help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:51:59+00:00Added an answer on June 16, 2026 at 12:51 am

    I think your “admin” variable is null. Do you call your constructor? If yes, are the parameters correct?

    Just write “private Admin admin” dont make the admin variable an Admin Object. Try initialize it or call the constructor properly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is a problem I come across every so often; I always end up
I have URLs which always end on a number, for example: String url =
I have got this error when using Enterprise Library 3.1 May 2007 version. We
In my applications I always end up implementing a Model-View-Presenter pattern and usually end
In my controller, I always end up with something like: [HttpPost] public ActionResult General(GeneralSettingsInfo
Whenever I run large scale monte carlo simulations in S-Plus, I always end up
I tracked down a memory leak with instruments. I always end up with the
I realize that the csv library in Python always generates DOS end-of-line characters. Even
I always wondered why there is no sort(v);// same as std::sort(v.begin(),v.end()) If I recall
Whenever I use WCF, I always try to make immutable classes that end up

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.