GT-R Register - Official Nissan Skyline and GTR Owners Club forum - View Single Post - Java help please
View Single Post
Old 31st October 2008, 08:41 AM   #2 (permalink)
moz
moz has no status.
GTR Register Member
 
Join Date: Mar 2005
Location: Finland
Cars owned: R32 GT-R
Posts: 281
First, the months are displayed twice because of this:

The combobox is created with a string[] parameter of values.
Code:
inputMonth = new JComboBox(months);
Then more values are put in the list (duplicating the entries).
Code:
for (int i = 0; i < 12; i++)
{
     inputMonth.addItem(months[i]);
}
JComboBox has one constructor like this:

Code:
JComboBox(Object[] items) 
Creates a JComboBox that contains the elements in the specified array
So you can either do this:

Code:
inputMonth = new JComboBox(); // No parameter
for (int i = 0; i < 12; i++) // Fill in values
{
     inputMonth.addItem(months[i]);
}
or simply this, as you have done and lose the for loop:
Code:
inputMonth = new JComboBox(months);
I'll look at the rest if I get time
__________________
moz is offline   Reply With Quote