当我更新列表中对象的状态时,ListView中listCell对象中的图标应该更改。 progress和ok png正常工作,但是当更改为任何其他png时,listCell对象将被删除。
让我们说状态从进度变为关键,然后删除listcell,但是使用ok.png代替,然后它就不会被删除。所以它似乎与图像有关。
package MMaaSCollector.windows;
import java.io.IOException;
import MMaaSCollector.Log;
import MMaaSCollector.systems.Host;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.Label;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.AnchorPane;
public class HostCellData {
@FXML private AnchorPane bg;
@FXML private Label displayName;
@FXML private Label type;
@FXML private ImageView status = new ImageView();
public HostCellData()
{
FXMLLoader fxmlLoader = new FXMLLoader(getClass().getResource("/MMaaSCollector/windows/HostListCell.fxml"));
fxmlLoader.setController(this);
try
{
fxmlLoader.load();
}
catch (IOException e)
{
throw new RuntimeException(e);
}
}
public void setInfo(Host host, double width) {
displayName.setText(host.getDisplayName());
type.setText(host.getType());
bg.setPrefWidth(width-17.0-17.0);
if (host.isStatusGathering()) {
Image progress = new Image("/MMaaSCollector/images/progress.gif");
status.setImage(progress);
Log.debugInfo(host.getDisplayName() + " has progress indicator.", 96);
} else if (host.isStatusFailed()) {
Image failed = new Image("/MMaaSCollector/images/fail.png");
status.setImage(failed);
Log.debugInfo(host.getDisplayName() + " has failed indicator.", 96);
} else if (host.isStatusOK()) {
Image ok = new Image("/MMaaSCollector/images/ok.png");
status.setImage(ok);
Log.debugInfo(host.getDisplayName() + " has ok indicator.", 96);
} else if (host.isStatusInfo()) {
Image info = new Image("/MMaaSCollector/images/info.png");
status.setImage(info);
Log.debugInfo(host.getDisplayName() + " has info indicator.", 96);
} else if (host.isStatusLow()) {
Image low = new Image("/MMaaSCollector/images/low.png");
status.setImage(low);
Log.debugInfo(host.getDisplayName() + " has low indicator.", 96);
} else if (host.isStatusWarning()) {
Image warning = new Image("/MMaaSCollector/images/warning.png");
status.setImage(warning);
Log.debugInfo(host.getDisplayName() + " has warning indicator.", 96);
} else if (host.isStatusCritical()) {
Image critical = new Image("/MMaaSCollector/images/critical.png");
status.setImage(critical);
Log.debugInfo(host.getDisplayName() + " critical indicator.", 96);
}
}
public AnchorPane getBg() {
return bg;
}
}
答案 0 :(得分:0)
找到它无法正常工作的原因。不得不在eclipse中更新项目。 现在,当图像同步时,它可以正常工作。