[英]How to display all the value from database in a JComboBox?
This code only display only one va, and repeat many times.这段代码只显示一个va,并且重复多次。 Hope someone can help me.
希望可以有人帮帮我。 Thanks a lot.
非常感谢。
private void originComboBox() {
scheControl = new ScheduleControl();
Schedule schedule = scheControl.getRecord();
String origin = schedule.getDeparture();
for(int i = 0; i < origin.length(); i++){
originCB.addItem(origin);
}
}
You are adding the same origin each time.您每次都添加相同的来源。 Shouln't it be origin[i] ?
不应该是 origin[i] 吗?
for(int i = 0; i < origin.length(); i++){
originCB.addItem(origin[i]);
}
String origin = schedule.getDeparture();
you could try this你可以试试这个
for(int i = 0; i < origin.length(); i++){
originCB.addItem(origin[i]);
}
where origin should be Array .其中 origin 应该是 Array 。
String origin[]={"A","B","C"};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.