JFreeChart's ChartViewer is not filling the entire tab space

A discussion forum for JFreeChart (a 2D chart library for the Java platform).
Locked
david.gilbert
JFreeChart Project Leader
Posts: 11734
Joined: Fri Mar 14, 2003 10:29 am
antibot: No, of course not.
Contact:

Re: JFreeChart's ChartViewer is not filling the entire tab space

Post by david.gilbert » Sun Jun 17, 2018 5:02 pm

I think all you need to add is:

Code: Select all

      chartViewer.setPrefHeight(300);
...because the preferred width and height of the ChartViewer are defaulting to 0.

You could also consider removing the VBox and second anchor pane, and add the ChartViewer directly to the first AnchorPane:

Code: Select all

        tab.setContent(anchorPane);
//        VBox vBox = new VBox();
//        anchorPane.getChildren().add(vBox);
//        AnchorPane.setBottomAnchor(vBox, 0.0);
//        AnchorPane.setLeftAnchor(vBox, 0.0);
//        AnchorPane.setRightAnchor(vBox, 0.0);
//        AnchorPane.setTopAnchor(vBox, 0.0);
//        vBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("BLUE"), CornerRadii.EMPTY, Insets.EMPTY)));
//        AnchorPane anchorPane1 = new AnchorPane();
//        vBox.getChildren().add(anchorPane1);
...at least for your demo app (maybe your real code has a more complex layout.
David Gilbert
JFreeChart Project Leader

:idea: Read my blog
:idea: Support JFree via the Github sponsorship program

Locked