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

后端 未结 3 886
北海茫月
北海茫月 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: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

提交回复
热议问题