Advertisement
tmax

NPE Bug

Jul 6th, 2014
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.38 KB | None | 0 0
  1. import javafx.animation.AnimationTimer;
  2. import javafx.application.Application;
  3. import javafx.collections.FXCollections;
  4. import javafx.collections.ObservableList;
  5. import javafx.scene.chart.XYChart;
  6. import javafx.stage.Stage;
  7.  
  8. import java.util.Random;
  9. import java.util.concurrent.ConcurrentLinkedQueue;
  10.  
  11. public class ExceptionTest extends Application {
  12.  
  13.     @Override
  14.     public void start(Stage primaryStage) throws Exception {
  15.         // Data
  16.         XYChart.Series<Double, Double> series = new XYChart.Series<>();
  17.         ConcurrentLinkedQueue<XYChart.Data<Double, Double>> fullDataQueue = new ConcurrentLinkedQueue<>();
  18.         ObservableList<XYChart.Data<Double, Double>> chartData = FXCollections.observableArrayList();
  19.  
  20.         series.setData(chartData);
  21.  
  22.         // Start adding data
  23.         final Random random = new Random();
  24.         for(int n = 0; n < 10000; ++n){
  25.             fullDataQueue.add(new XYChart.Data<>((double)n, random.nextDouble()));
  26.         }
  27.  
  28.         new AnimationTimer(){
  29.             @Override
  30.             public void handle(long now) {
  31.                 for (XYChart.Data<Double, Double> data : fullDataQueue){
  32.                     chartData.add(data);
  33.                 }
  34.             }
  35.         }.start();
  36.         System.out.println("Done testSeriesAddInAnimator()!");
  37.     }
  38.  
  39.     public static void main(String[] args) {
  40.         launch(args);
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement