Olá. Neste tópico eu gostaria se corrigir um erro que me encomoda bastante, bem, não é só esse erro desse tipo que meu programa tem, tem vários, porém esse me encomoda bastante, eu estou falando de um componente não ocupar todo o espaço de seu pai. Eu possuo uma ListView de PersonProgress (uma classe que eu criei que estende de StackPane), até aí tudo bem, dentro desse StackPane tem uma barra de progresso e uma Label que fica por sima da barra, e o resultado fica assim na lista:

Como está na imagem, o PersonProgress não ocupa toda a largura da ListView, e eu já tentei todo tipo de bind e gambiarra com width, mas não deu certo.
Esta é a classe:
import java.util.ArrayList;
import com.tkfentretenimento.meusdados.model.Download;
import com.tkfentretenimento.meusdados.model.Transfer;
import com.tkfentretenimento.meusdados.model.Upload;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.ProgressBar;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
public class PersonProgress extends StackPane{
private ProgressBar p = new ProgressBar();
private ArrayList<Upload> u = new ArrayList<Upload>();
private ArrayList<Download> d = new ArrayList<Download>();
private String deviceName;
public PersonProgress(String deviceName, ArrayList<Transfer> tr) {
this.getChildren().add(p);
for(Transfer t : tr){
if(t instanceof Download){
addDownload((Download) t);
}else if(t instanceof Upload){
addUpload((Upload) t);
}
}
this.deviceName = deviceName;
setMaxPercentValue();
VBox v = new VBox();
v.getChildren().add(new Label(deviceName));
v.setAlignment(Pos.CENTER);
this.getChildren().add(v);
//this.setMargin(this, new Insets(10.0));
}
public ArrayList<Upload> getU() {
return u;
}
public void setU(ArrayList<Upload> u) {
this.u = u;
}
public ArrayList<Download> getD() {
return d;
}
public void setD(ArrayList<Download> d) {
this.d = d;
}
public void addUpload(Upload u){
this.u.add(u);
setMaxPercentValue();
}
public void addDownload(Download down){
this.d.add(down);
setMaxPercentValue();
}
public boolean applyUpdates(ArrayList<Transfer> newTransfers){
boolean toReturn = false;
for(Transfer t : newTransfers){
if(t instanceof Download){
if(!this.d.contains(t)){
d.add((Download) t);
}else{
toReturn = incrementUpPercent((Download) t);
}
}else if(t instanceof Upload){
if(this.u.contains(t)){
if(!this.u.contains(t)){
u.add((Upload) t);
}else{
toReturn = incrementUpPercent((Upload) t);
}
}
}
}
setMaxPercentValue();
return toReturn;
}
public boolean incrementUpPercent(Upload up){
int index = 0;
for(Upload upl : this.u){
if(upl.equals(up)){
if(this.u.get(index).getPercent()!=up.getPercent()){
this.u.get(index).setPercent(up.getPercent());
return true;
}
}
++index;
}
return false;
}
public boolean incrementUpPercent(Download down){
int index = 0;
for(Download download : this.d){
if(download.equals(down)){
if(this.d.get(index).getPercent()!=down.getPercent()){
this.d.get(index).setPercent(down.getPercent());
return true;
}
}
++index;
}
return false;
}
private void setMaxPercentValue(){
long maxSize = 0;
double percentSum = 0;
System.out.println("Upload ? "+u.size());
System.out.println("Download ? "+d.size());
if(u!=null){
for(Upload up : u){
if(up.isRunning()){
maxSize+=up.getSize();
percentSum+=up.getPercent();
}
}
}
if(d!=null){
for(Download down : d){
if(down.isRunning()){
maxSize+=down.getSize();
percentSum+=down.getPercent();
}
}
}
p.setProgress((percentSum*100)/maxSize);
}
public String getDeviceName() {
return deviceName;
}
}
Alguém sabe qual é o problema da largura?
