Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

comboBox for 50 States using an array  RSS feed

 
Alisha Hager
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This is what I need to create:
This project focuses on demonstrating your understanding of GUI and event programming. Before attempting this project, be sure you have completed all of the reading assignments listed in the syllabus to date, participated in the weekly conferences, and thoroughly understand the examples throughout the chapters.

Enhance the form you created in homework 3 to add a JCombobox to select the user’s State of residence, and a group of JRadio buttons to indicate the user's gender. Once the user clicks on the JButton (created in homework 3) the application will display all of the user’s information in the JTextearea in a format similar to the following:

Name:
Age:
Gender:
Age Group:
State of Residence:
This is my code so far. I am having trouble with trying to select a state from my comboBox. My box prints out on the screen fine, but it will not allow me to select a state and print out a state. Any ideas of what I am doing wrong? I am new to event listeners. I was able to get the event listener to work for my radio buttons ok. But I am stuck on the comboBox.





 
Paul Clapham
Sheriff
Posts: 22185
38
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks pretty good to me (I think that using a JComboBox to select a state is a weird idea, but it looks like you're stuck with that design) but look at this:

Your "box" variable refers to the JComboBox containing the states -- and it's showing up on the screen just fine, you say, so that's so far so good. However...



When somebody selects a state from that list, a SubmitListener is poked and told to run its actionPerformed() method. Have a look at the SubmitListener class; is that what you want to happen when a state is selected?
 
Alisha Hager
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the advice! I will look at the submit listener class. There is so much to learn its a challenge to figure out how to go about setting up my code at times. Using a JComboBox to choose a state would not be my first choice either but thats what the instructions call for.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!