Updated to provided minimal reproducible example I have a program to takes in xml data, moves it into a arraylist and then displayed using JavaFX/FXML file. It works, but my right menu isn't as it used to be. It only shows "Export As" (zoom reset etc isn't there anymore), with a submenu, which doesn't display until mouseover. I have PNG, JPEG, PDF, SVG showing up, and they do work but I would like to add more features to the export. I've not been able to find clear resources to solve my problem.
Thanks
my Main:
import javafx.application.Application;
import javafx.application.Platform;
import javafx.fxml.FXMLLoader;
import javafx.scene.Parent;
import javafx.scene.Scene;
import javafx.stage.Stage;
public class Main extends Application {
public static void main(String[] args) {
launch(args);
}
public void start(Stage primaryStage) throws Exception {
Parent root = FXMLLoader.load(getClass().getResource("/ExportPDF.fxml"));
primaryStage.setTitle("Bare Export PDF");
primaryStage.setScene(new Scene(root, 1920, 1080));
primaryStage.sizeToScene();
System.out.println("javafx.runtime.version: " + System.getProperties().get("javafx.runtime.version"));
primaryStage.show();
primaryStage.setOnCloseRequest(e -> Platform.exit());
}
}
My FXML.
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<?import org.jfree.chart.fx.ChartViewer?>
<AnchorPane xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml" fx:controller="Controller"
prefHeight="1000.0" prefWidth="1900.0">
<Button fx:id="SubmitBtn" layoutX="10.0" layoutY="10.0" onAction="#submitButtonClicked" prefHeight="30.0" prefWidth="125.0" text="Submit" textFill="BLACK">
</Button>
<ChartViewer fx:id="chartViewer" layoutY="50.0" layoutX="50.0" prefWidth="500" prefHeight="500" disable="true"/>
</AnchorPane>
My Controller
import javafx.fxml.FXML;
import javafx.scene.control.Button;
import org.jfree.chart.fx.ChartViewer;
public class Controller {
@FXML
ChartViewer chartViewer;
@FXML
Button SubmitBtn = new Button("Submit");
public void submitButtonClicked() {
chartViewer.setDisable(false);
new bathChart("Number of Tracks", "Months", "Tracks", chartViewer);
}
}
My Method to call the chart once button is clicked
import org.jfree.chart.*;
import org.jfree.chart.fx.ChartViewer;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.renderer.category.StandardBarPainter;
import org.jfree.data.category.DefaultCategoryDataset;
import java.awt.*;
import java.util.ArrayList;
class bathChart {
bathChart(String title, String catAxisLabel, String valAxisLabel, ChartViewer chartViewer) {
DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(7445, "JFreeSVG", "Warm-up");
dataset.addValue(24448, "Batik", "Warm-up");
dataset.addValue(4297, "JFreeSVG", "Test");
dataset.addValue(21022, "Batik", "Test");
//Create the chart
JFreeChart chart = ChartFactory.createBarChart(
title, catAxisLabel, valAxisLabel, dataset,
PlotOrientation.VERTICAL, true, true, false);
String fontName = "Verdana";
StandardChartTheme theme = (StandardChartTheme)org.jfree.chart.StandardChartTheme.createJFreeTheme();
theme.setTitlePaint(Color.white);
theme.setExtraLargeFont(new Font(fontName,Font.PLAIN, 18)); //title
theme.setLargeFont(new Font(fontName,Font.BOLD, 15)); //axis-title
theme.setRegularFont(new Font(fontName,Font.PLAIN, 11));
theme.setRangeGridlinePaint(Color.decode("#C0C0C0"));
theme.setPlotBackgroundPaint(Color.decode("#2b496f"));
theme.setChartBackgroundPaint(Color.decode("#004872"));
theme.setGridBandPaint(Color.red);
theme.setBarPainter(new StandardBarPainter());
theme.setAxisLabelPaint(Color.white);
theme.apply(chart);
chart.getCategoryPlot().setOutlineVisible(false);
chart.getCategoryPlot().getRangeAxis().setAxisLineVisible(true);
chart.getCategoryPlot().getRangeAxis().setTickMarksVisible(true);
chart.getCategoryPlot().setRangeGridlineStroke(new BasicStroke());
chart.getCategoryPlot().getRangeAxis().setTickLabelPaint(Color.white);
chart.getCategoryPlot().getDomainAxis().setTickLabelPaint(Color.white);
chart.setTextAntiAlias(true);
chart.setAntiAlias(true);
chart.getCategoryPlot().getRenderer().setSeriesPaint(0, Color.decode("#4572a7"));
chartViewer.setChart(chart);
}
}