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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T01:56:56+00:00 2026-05-21T01:56:56+00:00

This is a HW problem. I keep getting the following error on screen related

  • 0

This is a HW problem. I keep getting the following error on screen related to my if(i==3) statement…

“Exception in thread “AWT-EventQueue-1″ java.lang.NullPointerException
at ui.panels.ChoicePanel$1.itemStateChanged(ChoicePanel.java:31)”

…Can someone point me in the right direction? Here is my code. Thanks for your time.

package ui.panels;

import java.awt.Choice;
import java.awt.Panel;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import model.Model;
import interfaces.Resettable;

public class ChoicePanel extends Panel implements Resettable{
  public int i = 0;
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  Model model;
  Choice selection;

  public ChoicePanel(Model mdl) {

      selection = new Choice();
      for (String msg : Model.selections) {
          selection.add(msg);
      }
      selection.addItemListener(new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            if(i==3) {//drop down clicked three times)
              System.out.println("PING");
            }else{
              model.setMessage(selection.getSelectedItem());
              //this line is what sends a value to shape that is drawn on screen
              //NOT line 36 of GUIDemo.java
              //
              model.setCurrentShapeType(selection.getSelectedItem());
              model.repaint();
              ++i;
            }

          }

      });
      this.add(selection);
  }

  public void resetComponents() {
    //this resets the drop down list selection array to the first choice on the list
    selection.select(0);
    //this sets selected item in the selection array set in the above line
    model.setMessage(selection.getSelectedItem());
    //model.repaint();
  }

}
  • 1 1 Answer
  • 1 View
  • 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-05-21T01:56:56+00:00Added an answer on May 21, 2026 at 1:56 am

    I believe you are not initializing model, which would give a NullPointerException when it was first dereferenced.

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

Sidebar

Related Questions

I'm having this problem where I keep getting this error in my console: *
I keep getting the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException',
I keep getting 500 (Internal Server Error) and I suspect this is because I
I keep getting the following error when trying to parse some html using BeautifulSoup:
I keep getting the following error: You have an error in your SQL syntax;
I keep getting the following error message when I run my code in debug.
On one of my php pages, I keep getting the following error: SQLSTATE[23000]: Integrity
I keep getting the following error when trying to deploy my app with the
I keep coming back to this problem, since there doesn't seem to be a
So I have this problem with strings and switch-case, and I'll try to keep

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.