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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T02:20:22+00:00 2026-05-20T02:20:22+00:00

I’ve almost got my asignment done. Yayy! But…. I have two problems in my

  • 0

I’ve almost got my asignment done. Yayy! But…. I have two problems in my handler. For one, I have a public void itemStateChanged(ItemEvent e) method that is supposed to print a registrants name to a text field, plus the type of registration he is (student, business, complimentary). I have this working, only it prints twice to the text area. I don’t get that. Also, there is a ‘calculate charges’ button which is used to…well, calculate the charges. When the button is clicked, the action event is supposed to check to make sure that a combo box (in a class called regPanel) does not have “Please select a registration type” which is element 0 in an object array. The way I have it now, if I don’t pick something from the combobox (leaving it on element 0), I get the error message, but then the program prints to the textfield anyways. It is not supposed to. It is only supposed to print the error box, then allow the user to make the proper selections. Any advice would be appreciated. Here is the class:

public class ConferenceHandler implements ActionListener, FocusListener, ItemListener
{
    protected final static String ERROR_TEXT = "Please enter a name";
    protected ConferenceGUI gui;  //reference the ConferenceGUI panel
    /**Constructor*/
    public ConferenceHandler(ConferenceGUI gui) {this.gui = gui;}     


            if (gui.regPanel.getRegType() == "Please select a type")
                JOptionPane.showMessageDialog(null, "Please select a registration type",
                    "Type Error",JOptionPane.ERROR_MESSAGE);
            //prints to textarea if registrant will be attending keynote or not
            else if (gui.regPanel.regCheckBox.isSelected())
                gui.textArea.append("\nKeynote address will be attended");
            else

Did a little more googling, and figured out the problem with the double firing of the itemStateChanged affair. Trimmed all of the extra code out, because I’m pretty sure that all I need is a loop of some sort around here. When I put a while or do-while loop, all that happens is the JOptionPane comes up and won’t go away. I need to validate that the user has entered an appropriate checkbox selection, though.

  • 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-20T02:20:23+00:00Added an answer on May 20, 2026 at 2:20 am

    I have this working, only it prints twice to the text area.

    You still haven’t posted a SSCCE that demonstrates the problem as you where asked in a previoius question.

    Copying and pasting a few lines of code from your real problem does not help you isolate the problem.

    As a beginner, you need to learn how to simplify problems. Once you simplify the problem it is easier to find and solve the problem.

    In this case a working SSCCE will be about 20 lines of code. A couple lines to create the GUI, a few more to add the compnonents and a few more to create the ItemListener.

    Post your SSCCE and I’ll post the answer to your question. This is a common mistake when working with an ItemListener. I could probably give you the answer without seeing your SSCCE, but you need to learn how to create a SSCCE for when you encounter more complex problems. So this question is a good place to start.

    Maybe looking at the section from the Swing tutorial on How to Write an Item Listenerwill help you understand what is happening.

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

Sidebar

Related Questions

I have a French site that I want to parse, but am running into
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Seemingly simple, but I cannot find anything relevant on the web. What is the
this is what i have right now Drawing an RSS feed into the php,
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a bunch of posts stored in text files formatted in yaml/textile (from
I am trying to loop through a bunch of documents I have to put

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.