String[] months = {"January", "February", "March", "April", "Mei", "June",
"July", "August", "September", "October", "November", "December"};
months[1].toString() o (String)months[1],
Pero no entiendo porque me marca error eclipse, tengo una clase la cual es:
Código PHP:
private class TestItem {
private String shortName;
private String longName;
public TestItem( String s, String l ) {
shortName = s;
longName = l;
}
public String toString() {
return shortName;
}
public String getToolTipText() {
return longName;
}
}
Pero si yo hago esto:
Código PHP:
Vector v = new Vector();
for(int i=0;i<=months.length;i++){
v.add( new TestItem( months[i].toString(), "Pruebas" ) );
}
JComboBox comboBox = new JComboBox(v);
Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 12
at comboBox.ComboBoxCreate.initialize(ComboBoxCreate. java:37)
Si yo hago esto:
Código PHP:
Vector v = new Vector();
for(int i=0;i<=months.length;i++){
v.add( new TestItem( "January", "Pruebas" ) );
}
JComboBox comboBox = new JComboBox(v);
Espero me puedan ayudar,
Gracias!!