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 8661083
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:24:41+00:00 2026-06-12T16:24:41+00:00

I am trying to build a simple gui program. Everything worked well because I

  • 0

I am trying to build a simple gui program. Everything worked well because I tested the classes before adding some GUI components such as in SWING and AWT. However when I tried some input and press the submit button it gives me this error.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at com.simpleAccountEntry.SimpleAccountListener.actionPerformed(SimpleAccountListener.java:15)
    at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2012)
    at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2335)
    at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:404)
    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:6389)
    at javax.swing.JComponent.processMouseEvent(JComponent.java:3268)
    at java.awt.Component.processEvent(Component.java:6154)
    at java.awt.Container.processEvent(Container.java:2045)
    at java.awt.Component.dispatchEventImpl(Component.java:4750)
    at java.awt.Container.dispatchEventImpl(Container.java:2103)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4633)
    at java.awt.LightweightDispatcher.processMouseEvent(Container.java:4297)
    at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4227)
    at java.awt.Container.dispatchEventImpl(Container.java:2089)
    at java.awt.Window.dispatchEventImpl(Window.java:2518)
    at java.awt.Component.dispatchEvent(Component.java:4576)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:672)
    at java.awt.EventQueue.access$400(EventQueue.java:96)
    at java.awt.EventQueue$2.run(EventQueue.java:631)
    at java.awt.EventQueue$2.run(EventQueue.java:629)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:116)
    at java.awt.EventQueue$3.run(EventQueue.java:645)
    at java.awt.EventQueue$3.run(EventQueue.java:643)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.AccessControlContext$1.doIntersectionPrivilege(AccessControlContext.java:105)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:642)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:275)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:200)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:190)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:185)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:177)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:138)

I tried to debug it since yesterday but I couldn’t find where I made a mistake. I tried to check this error code:

 com.simpleAccountEntry.SimpleAccountListener.actionPerformed(SimpleAccountListener.java:15)

and it points to this class:

public class SimpleAccountListener implements ActionListener{

    private SimpleAccountActionsPanel listen;
    
    public SimpleAccountListener(SimpleAccountActionsPanel functionPanel){
        listen = functionPanel;
    }
    
    public void actionPerformed(ActionEvent e){
        listen.recordPatient(); //SimpleAccountListener.java: 15
    }
}

listen.recordPatient() can be found in this class along with other methods I have written

EDIT

 public class SimpleAccountActionsPanel extends JPanel{
    
        private SimpleAccountPanel account = new SimpleAccountPanel();
**//Initialize this line
        static private SimpleAccountActionsPanel perform = new SimpleAccountActionsPanel();**
        
        private DetailsEntry<Details> setPatient = new DetailsEntry<Details>();
        
        static private JButton submit;
        static private JButton delete;
        
        public SimpleAccountActionsPanel(){
            this.setLayout(new GridLayout(1,2));
                                                                                        
            
            submit = new JButton("Submit Entries");
            delete = new JButton("Delete Entries");
            
            submit.setBackground(Color.DARK_GRAY);
            submit.setForeground(Color.ORANGE);
            
            delete.setBackground(Color.DARK_GRAY);
            delete.setForeground(Color.ORANGE);
            
            this.add(submit);
            this.add(delete);
            
            //SimpleAccountPanel varFields = new SimpleAccountPanel();
            SimpleAccountListener performFn = new SimpleAccountListener(perform);
            submit.addActionListener(performFn);
        }
        
        public void recordPatient(){
            String name = account.getEnterName().getText();
            String dob = account.getEnterDOB().getText();
            String doc = account.getEnterDr().getText();
            String allergy = account.getAllergies().getText();
            String room = account.getEnterRoomNo().getText();
            int convRoom = Integer.parseInt(room);
            
            setPatient.addEntry(new Details(name, dob, doc, allergy, convRoom));
        }
    }

Anyone care to help me out? If you need more of the classses I implemented I can post it just let me know Thanks in advance.

EDIT

Thanks to Max and MadProgrammer I initialized perform as suggested program now works perfectly.

  • 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-12T16:24:42+00:00Added an answer on June 12, 2026 at 4:24 pm

    You’re passing SimpleAccountListener a reference to the variable perform which isn’t initialised in the constructor of SimpleAccountActionsPanel, hence the NPE

    SimpleAccountListener performFn = new SimpleAccountListener(perform); // <-- perform is not initialised...
    

    I’m trying to figure out why you didn’t just pass this?

    SimpleAccountListener performFn = new SimpleAccountListener(this);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just started trying to build simple GUIs because I've always used command-line script
When trying to build a simple test program that uses atomic operations, I get
I'm trying to build a simple html page which include some text paragraph, during
I'm trying to build a simple application, with the finished program looking like this
I am trying to build a simple menu-based GUI with J2ME. The menu entries
I'm trying to build a simple parser, and since InputStream doesn't have some peek-like
I'm trying to build a simple component extending spark.components.Group to have a background color,
I am trying to build a simple Java GUI (I've been learning for only
I'm trying to build a simple .Net wrapper around some basic C++ code. The
I trying to build a simple lib for persistence with guice persist and some

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.