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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T03:47:06+00:00 2026-05-21T03:47:06+00:00

Disclaimer: this is a (frustrating) homework related problem. I’m having odd results when I

  • 0

Disclaimer: this is a (frustrating) homework related problem.

I’m having odd results when I draw my objects on screen. I want this…I draw first object then draw second object when I select third object to draw the screen clears and I have to start the process again….what i get is…I draw first object, I draw second object, I go to draw third object screen clears…I select third object but SECOND object is what appears on screen. Please help point me in right direction.

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) {
      model = mdl;
      selection = new Choice();
      for (String msg : Model.selections) {
          selection.add(msg);
      }
      selection.addItemListener(new ItemListener() {

          public void itemStateChanged(ItemEvent e) {
            if(i==1) {//drop down clicked three times)
              System.out.println("ChoicePanel says i == "+i);
              model.setMessage(selection.getSelectedItem());
              model.setCurrentShapeType(selection.getSelectedItem());
              //model.repaint();
              ++i;
            }else if(i==2){
              System.out.println("ChoicePanel says i == "+i);
              model.setMessage(selection.getSelectedItem());
              //model.setCurrentShapeType(selection.getSelectedItem());
              model.resetComponents();
              //--i;
            }else{
              model.setMessage(selection.getSelectedItem());
              //this line is what sends a value to shape that is drawn on screen
              model.setCurrentShapeType(selection.getSelectedItem());
              //model.repaint();
              ++i;
            }
          }

      });
      this.add(selection);
  }

  public void resetComponents() {
    System.out.println("resetComponents from ChoicePanel");
    //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());
    i=0;
    model.repaint();
  }

}
  • 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-05-21T03:47:07+00:00Added an answer on May 21, 2026 at 3:47 am

    Within else if(i==2){ ... } you don’t increment i, it’ll never get past 2.

    } else if(i==2){
        System.out.println("ChoicePanel says i == "+i);
        model.setMessage(selection.getSelectedItem());
        //model.setCurrentShapeType(selection.getSelectedItem());
        model.resetComponents();
        ++i; // Increment here
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Disclaimer: this question is directly related to my programming homework. My C++ assignment consists
Disclaimer: This is homework. I am attempting it and do not expect or want
Disclaimer: This is a homework problem. As should be evident, I am trying to
Disclaimer: this was a homework problem. The deadline has passed now, so discussions can
Disclaimer: This is my first time writing unit tests...be gentle! :) I am trying
Disclaimer: not sure this is WordPress related or not. I'm following a simple tutorial
Full disclaimer: this is not really a homework, but I tagged it as such
Disclaimer: this question is purely informational and does not represent an actual problem I'm
Disclaimer: this is homework. I have a SAS dataset of: ID VAL YEAR I
Disclaimer: This is for a homework assignment, but the question is not regarding the

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.