2016-05-11 75 views
0

當我更新列表中對象的狀態時,ListView中listCell對象中的圖標應該更改。進度和OK png的工作,因爲它應該,但是當改變到任何其他PNG,listCell對象被刪除。更新圖像時listcell消失

可以說狀態從進度變爲關鍵狀態,然後刪除listcell,但是使用ok.png代替,那麼它不會被刪除。所以它似乎與圖像有關。

critical pictue

ok picture

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

這是所有的代碼是什麼? – Elltz

回答

0

找到爲什麼它不工作的原因。必須在eclipse中更新該項目。 現在,當圖像同步時,它就像它應該那樣工作。