Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8125375

Charts - setLabelsVisible(false) crashes with NullPointerException

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 7u6
    • Fix Version/s: 8
    • Component/s: javafx
    • Labels:

      Description

      Chart crashes if I setLabelsVisible(false):

      Caused by: java.lang.NullPointerException
      at javafx.scene.chart.PieChart.layoutChartChildren(PieChart.java:548)
      at javafx.scene.chart.Chart$1.layoutChildren(Chart.java:84)



      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.stage.Stage;
      import javafx.animation.KeyFrame;
      import javafx.animation.Timeline;
      import javafx.collections.FXCollections;
      import javafx.event.ActionEvent;
      import javafx.event.EventHandler;
      import javafx.scene.Node;
      import javafx.scene.chart.PieChart;
      import javafx.util.Duration;

      /**
       * An advanced pie chart with a variety of actions and settable properties.
       *
       * @see javafx.scene.chart.PieChart
       * @see javafx.scene.chart.Chart
       */
      public class TestApp3 extends Application {
          private int itemNameIndex = 1;

          private void init(Stage primaryStage) {
              Group root = new Group();
              primaryStage.setScene(new Scene(root));
              root.getChildren().add(createChart());
          }

          protected PieChart createChart() {
              final PieChart pc = new PieChart(FXCollections.observableArrayList(
                  new PieChart.Data("Sun", 20),
                  new PieChart.Data("IBM", 12),
                  new PieChart.Data("HP", 25),
                  new PieChart.Data("Dell", 22),
                  new PieChart.Data("Apple", 30)
              ));
              pc.setLabelsVisible(false);
              // setup chart
              pc.setId("BasicPie");
              pc.setTitle("Pie Chart Example");
              return pc;
          }

          @Override public void start(Stage primaryStage) throws Exception {
              init(primaryStage);
              primaryStage.show();
          }
          public static void main(String[] args) { launch(args); }
      }

        Attachments

          Activity

            People

            • Assignee:
              psomashe Parvathi Somashekar (Inactive)
              Reporter:
              cschudtjfx Christian Schudt (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: