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

On PieChart resize crazy repaint

    Details

      Description

      When resizing the Swing JFrame which contains panel with PieChart, the paint method paints something crazy.

      SSCCE:
      public class PieChartSample2 {

          private static PieChart chart;

          private static JFXPanel fxpanel = new JFXPanel();

          public static void main(String[] args) {
              final JFrame frame = new JFrame();
              frame.getRootPane().setOpaque(false);
              frame.setSize(500, 500);
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              final JPanel panel = new JPanel(new BorderLayout());
              panel.setOpaque(false);
              panel.setBorder(BorderFactory.createLineBorder(Color.RED));

              fxpanel.setBackground(Color.YELLOW);
              panel.add(fxpanel, BorderLayout.CENTER);

              Platform.runLater(new Runnable() {
                  @Override
                  public void run() {
                      createScene();
                  }
              });

              frame.setContentPane(panel);

              SwingUtilities.invokeLater(new Runnable() {
                  @Override
                  public void run() {
                      frame.setVisible(true);
                  }
              });
          }

          protected static void createScene() {
              ObservableList<PieChart.Data> pieChartData = FXCollections.observableArrayList(new PieChart.Data("Grapefruit", 13), new PieChart.Data("Oranges", 25), new PieChart.Data("Plums", 10), new PieChart.Data("Pears", 22), new PieChart.Data("Apples", 30));
              chart = new PieChart(pieChartData);

              chart.setLegendVisible(false);
              chart.setAnimated(true);

              decorateWithStyle(chart);

              Scene scene = new Scene(chart);

              chart.setTitle("Imported Fruits");

              fxpanel.setScene(scene);
          }

          private static void decorateWithStyle(PieChart pieChart) {
              pieChart.setStyle("-fx-background-color: #525252");
              pieChart.lookup(".chart-pie-label").setStyle("-fx-fill: #ffffff; -fx-font-size: 0.9em;");
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              ant Anton Tarasov
              Reporter:
              duke J. Duke (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: