我有一个JComboBox和一个名为clsPais的类:
.then()
在我的JFrame代码中,我把:
//We create an empty array to store our promises
var arrayOfPromises = [];
for (var i = 0; i < 10; i++) {
//We push each promise to the array
arrayOfPromises.push(readFromDatabase(i));
}
//We wait until all promises have
Promise.all(arrayOfPromises)
.then(function(arrayOfResults){
//arrayOfResults is an array with the resolved values from the 'readFromDatabase' function
})
.catch(function(){
//Handle errors
});
在这里,我有一个错误,告诉我&#34;不兼容的类型:clsPais canot可以转换为字符串&#34;。 我的JComboBox中的addItem只接受String参数。 我该怎么办?
谢谢
答案 0 :(得分:1)
你可以这样做..
stonesRemoved = StoneRemover (randomNumber, playerCount);
答案 1 :(得分:1)
您需要cmbPaises
类型clsPais
而不是String
:
JComboBox<clsPais> cmbPaises = new JComboBox<>();
cmbPaises.addItem(p1);
cmbPaises.addItem(p2);
BTW,在Java中,惯例是类名以caplital字母开头。