列表中有奇怪边框的JavaFx

列表中有奇怪边框的JavaFx,java,javafx,java-8,Java,Javafx,Java 8,我有一个使用无流项目的JavaFX列表。但我得到了一个奇怪的边界(我没有启用任何边界并强制边界的宽度为0px),它存在并具有渐变效果: 当我将单元格背景插图设置为-1时,边框消失了,所以我认为这个问题与背景有关。虽然这不是一个解决方案,因为如果启用边界(我想要),渐变效果仍然存在 有人知道我怎样才能摆脱这个边界吗 我在最新的201版本中使用JavaFX8 编辑:我制作了以下示例来说明问题: import javafx.application.Application; import javafx

我有一个使用无流项目的JavaFX列表。但我得到了一个奇怪的边界(我没有启用任何边界并强制边界的宽度为0px),它存在并具有渐变效果:

当我将单元格背景插图设置为-1时,边框消失了,所以我认为这个问题与背景有关。虽然这不是一个解决方案,因为如果启用边界(我想要),渐变效果仍然存在

有人知道我怎样才能摆脱这个边界吗

我在最新的201版本中使用JavaFX8

编辑:我制作了以下示例来说明问题:

import javafx.application.Application;
import javafx.collections.FXCollections;
import javafx.collections.ObservableList;
import javafx.scene.Scene;
import javafx.scene.paint.Color;
import javafx.scene.text.Text;
import javafx.scene.text.TextFlow;
import javafx.stage.Stage;
import org.fxmisc.flowless.Cell;
import org.fxmisc.flowless.VirtualFlow;
import org.fxmisc.flowless.VirtualizedScrollPane;

public class Main extends Application {

  private ObservableList<Line> logLines;

  private VirtualFlow<Line, Cell<Line, LineCell>> listView;

  private VirtualizedScrollPane<VirtualFlow> listScrollPane;

  public static void main(String[] args) {
    launch(args);
  }

  public void start(Stage primaryStage) {

    logLines = FXCollections.observableArrayList();
    for(int i=1; i < 50; i++) {
      logLines.add(new Line("Line "+i));
    }

    listView = VirtualFlow.createVertical(logLines, (line) -> Cell.wrapNode(new LineCell(line)));
    listScrollPane = new VirtualizedScrollPane<>(listView);

    Scene scene = new Scene(listScrollPane, 200, 600, Color.BLACK);

    primaryStage.setScene(scene);
    primaryStage.show();
  }


  private class Line {

    private String text;

    public Line(String text) {
      this.text = text;
    }

    public String getText() {
      return text;
    }
  }

  private class LineCell extends TextFlow {
    public LineCell(Line line) {
      super();
      Text t = new Text(line.getText());
      t.setFill(Color.BLACK);
      super.setStyle("-fx-background-color: green;");
      super.getChildren().add(t);
    }
  }
}
导入javafx.application.application;
导入javafx.collections.FXCollections;
导入javafx.collections.ObservableList;
导入javafx.scene.scene;
导入javafx.scene.paint.Color;
导入javafx.scene.text.text;
导入javafx.scene.text.TextFlow;
导入javafx.stage.stage;
导入org.fxmisc.flowless.Cell;
导入org.fxmisc.flowless.VirtualFlow;
导入org.fxmisc.flowless.VirtualizedScrollPane;
公共类主扩展应用程序{
私人可观测对数线;
私有虚拟流列表视图;
私有虚拟化滚动窗格列表滚动窗格;
公共静态void main(字符串[]args){
发射(args);
}
公共无效开始(阶段primaryStage){
logLines=FXCollections.observableArrayList();
对于(int i=1;i<50;i++){
添加(新行(“行”+i));
}
listView=VirtualFlow.createVertical(logLines,(line)->Cell.wrapNode(newlinecell(line));
listScrollPane=新的虚拟化ScrollPane(listView);
场景=新场景(listScrollPane,200600,Color.BLACK);
初级阶段。场景(场景);
primaryStage.show();
}
私人班线{
私有字符串文本;
公用行(字符串文本){
this.text=文本;
}
公共字符串getText(){
返回文本;
}
}
私有类LineCell扩展了TextFlow{
公共行单元格(行){
超级();
Text t=新文本(line.getText());
t、 设置填充(颜色:黑色);
super.setStyle(“-fx背景色:绿色;”);
super.getChildren().add(t);
}
}
}

谢谢

我找到了解决这个问题的办法。现在它扩展了StackPane,而不是LineCell扩展TextFlow,我将TextFlow添加到StackPane

  private class LineCell extends StackPane {
    public LineCell(Line line) {
      super();
      Text t = new Text(line.getText());
      t.setFill(Color.BLACK);

      TextFlow tf = new TextFlow(t);
      super.setStyle("-fx-background-color: green;");
      super.getChildren().add(tf);
    }
  }

我也有同样的问题。你找到解决方案了吗?嗨@doombingerbg,我已经发布了解决方案,非常感谢3.