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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T03:58:31+00:00 2026-06-06T03:58:31+00:00

I keep getting a Run Time error that says I am having an Exception

  • 0

I keep getting a Run Time error that says I am having an Exception in thread “AWT-EventQueue-0” java.lang.NullPointerException it is saying a [line 65] but to me it just looks like a basic if statement. I can give some background. this frame is call from a sequence of frames that is then once the state is selected sent to a new frame that contains states A-C cities. This current frame will work only when Alabama is not the state selected. (I have not created the other frames for the other states hence why they are commented out) I can put up the code to the other frame it is supposed to call if anyone needs it but I figured that this was a lot of code to begin with.
Thanks in advance for the help everybody.

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionListener;
import java.awt.event.*;
import java.io.*;
import java.util.*;

public class WetBulbByLocationFrameStates3 extends JFrame
{
  public JLabel stateLabel;
  public JPanel statePanel = new JPanel();
  public JComboBox stateBox;
  public String [] unitedStates = {"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "District of Columbia", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "South Pacific Islands", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
  public String [] canadianProvinces = {"Alberta", "British Columbia", "Manitoba", "New Brunswick", "Newfoundland and Labrador", "Northwest Territories", "Nova Scotia", "Nunavut", "Ontario", "Prince Edward Island", "Quebec", "Saskatchewan", "Yukon Territory"};
  public JButton nextButton = new JButton("Next");
  public JPanel buttonPanel = new JPanel();
  public String state;
  public String countryGIVEN;

  public WetBulbByLocationFrameStates3(String country)
  {
    Toolkit toolkit = Toolkit.getDefaultToolkit();
    Dimension dimensions = toolkit.getScreenSize();
    int x = (dimensions.width - 315)/2; 
    int y = (dimensions.height - 250)/2;
    setBounds(x, y, 315, 250); 
    setVisible(true);
    setResizable(false);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    countryGIVEN = country;

    nextButton.addActionListener(new ButtonListener3());

    if (country.equals("United States of America"))
    {
      stateBox = new JComboBox(unitedStates);
      setTitle("Select State");
      stateLabel = new JLabel("State");
    }
    else if (country.equals("Canada"))
    {
      stateBox = new JComboBox(canadianProvinces);
      setTitle("Select Province");
      stateLabel = new JLabel("Province");
    }

    stateBox.addActionListener(new ComboBoxListener2());

    statePanel.add(stateLabel);
    statePanel.add(stateBox);

    add(statePanel, BorderLayout.CENTER);

    buttonPanel.add(nextButton);

    add(buttonPanel, BorderLayout.SOUTH);
  }
  private class ButtonListener3 implements ActionListener
  {
    @Override
    public void actionPerformed(ActionEvent e)
    {
      if (countryGIVEN.equals("United States of America"))
      {
        if (state.equals("Alabama"))
        {
          JFrame wbfs1 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("Alaska"))
        {
          JFrame wbfs2 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("Arizona"))
        {
          JFrame wbfs3 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("Arkansas"))
        {
          JFrame wbfs4 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("California"))
        {
          JFrame wbfs5 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("Colorado"))
        {
          JFrame wbfs6 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
        else if (state.equals("Connecticut"))
        {
          JFrame wbfs7 = new WetBulbByLocationFrameStateGroupA_C(state);
        }
      }
    }
  }
  private class ComboBoxListener2 implements ActionListener
  {
    @Override
    public void actionPerformed(ActionEvent e)
    {
      state = (String)stateBox.getSelectedItem();
    }
  }
}

PS here’s the error when selecting Alabama.

Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
    at WetBulbByLocationFrameStates3$ButtonListener3.actionPerformed(WetBulbByLocationFrameStates3.java:65)
    at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
    at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
    at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
    at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
    at java.awt.Component.processMouseEvent(Unknown Source)
    at javax.swing.JComponent.processMouseEvent(Unknown Source)
    at java.awt.Component.processEvent(Unknown Source)
    at java.awt.Container.processEvent(Unknown Source)
    at java.awt.Component.dispatchEventImpl(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
    at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
    at java.awt.Container.dispatchEventImpl(Unknown Source)
    at java.awt.Window.dispatchEventImpl(Unknown Source)
    at java.awt.Component.dispatchEvent(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$000(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.awt.EventQueue$4.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
  • 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-06T03:58:34+00:00Added an answer on June 6, 2026 at 3:58 am

    Line 65 is this one:

    if (state.equals("Alabama"))
    

    If you look through the previous code, nothing has initialized state so its value will be null.

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

Sidebar

Related Questions

I'm trying this SQL statement but I keep getting an error Run-time error '3061':
I keep getting this error when I run my web app (asp.net mvc) in
I keep getting the following error when trying to run a login script I
I keep getting the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
I'm getting the error Error for /la/truckpage java.lang.NoClassDefFoundError: Could not initialize class com.google.apphosting.runtime.security.shared.stub.java.net.Proxy For
Problem is that I keep getting the 'No Such Slot' runtime error in Qt
When I run the following code, I keep getting this error: Traceback (most recent
I am trying to run make on a PintOS makefile but I keep getting
Keep getting this error after inserting a subdatasheet into a query and trying to
Keep getting the error Arguments are not sufficiently instantiated for the multiplication by addition

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.