How to correctly add new data to TableView and scroll to it

后端 未结 3 857
北海茫月
北海茫月 2020-12-20 17:14

Problem

I want to add data dynamically to a TableView and scroll to the new data\'s position. But when the rows in the TableView reach the ViewPort

相关标签:
3条回答
  • 2020-12-20 17:18

    I dont find a solution but the problem is not about using scrollTo() method it's always happen when you're scroll to bottom (even manually) and increase the window height when the scroll disappear i don't know why need to open a bug ticket

    0 讨论(0)
  • 2020-12-20 17:29

    I solved this problem using fixed cells..

    listCategory.setFixedCellSize(40); 
    

    or

    -fx-fixed-cell-size : 40;
    
    0 讨论(0)
  • 2020-12-20 17:36

    Suppress the warning by resetting the log manager:

    import javafx.application.*;
    import javafx.stage.*;
    import javafx.scene.*;
    import javafx.scene.control.*;
    import javafx.scene.control.cell.*;
    import javafx.scene.layout.*;
    import javafx.beans.property.*;
    import javafx.collections.*;
    
    import java.util.logging.LogManager;
    
    public class TableViewSample extends Application {
      // ... setup ...
    
      public static void main(String[] args) {
    
        // Suppress the warning message when the Add button is clicked.
        LogManager.getLogManager().reset();
    
        launch(args);
      }
    

    This will affect the entire application's logger. If that is not desired, change the logging level for the offending class (com.sun.javafx.scene.control.skin.VirtualFlow) to Level.OFF.

    See also:

    • http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8140504
    • http://bugs.java.com/bugdatabase/view_bug.do?bug_id=8089472

    Since this is a warning message, it can probably be ignored, and therefore suppressed. As far as I can tell, the new row is added successfully. Here is the offending code that was checked in, which, IMO, violates the principle of least astonishment:

    • http://hg.openjdk.java.net/openjfx/8u-dev/rt/rev/92396a5f81f2#l2.60
    0 讨论(0)
提交回复
热议问题