Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

How would I make a combo box do this?

  Asked By: Emily    Date: Jun 11    Category: Java    Views: 709

I was wondering if there is a way for a combo box to work
like this

I have it so it is finding the ages of a member by years in a combo

How could i make it so that it goes like this
As a combo box?

Does anyone have any examples that i could look at .



2 Answers Found

Answer #1    Answered By: Funsani Chalthoum     Answered On: Jun 11

Can you explain this better? You need something finds the interval of ages
of someone in a JComboBox?

Answer #2    Answered By: Randall Franklin     Answered On: Jun 11

This implementation is easy. Use String arrays to build your combobox.

String[] values = new String[3]; // I am not 100% sure with this syntax. Just
check it
values[0] = "15-25"
values[1] = "26-30"

JComboBox age = new JComboBox[values];

Use this combobox  in your program by adding it to your panel.

To retrieve the information entered by the user, get the selected index value.
using a simple switch statement or a if-else u can retrieve the values.

Didn't find what you were looking for? Find more on How would I make a combo box do this? Or get search suggestion and latest updates.