2013-08-29 18 views
0

解除引用這是爲什麼標籤在JavaFX中拒絕以下字符串一次從intINT無法在JavaFX的

final int moonPhase = m.illuminatedPercentage(); 
System.out.println("The moon is " + moonPhase + "% full"); 
System.out.println("The next full moon is on: " + MoonPhaseFinder.findFullMoonFollowing(Calendar.getInstance())); 
System.out.println("The next new moon is on: " + MoonPhaseFinder.findNewMoonFollowing(Calendar.getInstance())); 

myLabel.setText(moonPhase.toString()); 

我收到以下錯誤轉化

error: int cannot be dereferenced myLabel.setText(moonPhase.toString()); 

回答

1

您不能致電toString()int。使用Integer或寫入

myLabel.setText("" + moonPhase);