/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package test; import java.net.URL; import javafx.application.Application; import javafx.collections.FXCollections; import javafx.scene.Scene; import javafx.scene.chart.Chart; import javafx.scene.chart.LineChart; import javafx.scene.chart.NumberAxis; import javafx.stage.Stage; /** * * @author fabriceb */ public class Main extends Application { /** * @param args the command line arguments */ public static void main(String[] args) { launch(args); } @Override public void start(Stage primaryStage) { NumberAxis xAxis = new NumberAxis(0, 5, 2); xAxis.setLabel("Value"); NumberAxis yAxis = new NumberAxis(0, 64, 10); yAxis.setLabel("Result"); LineChart.Series series = new LineChart.Series<>(); series.setName("y = 2^x"); for (int i = 0 ; i <= 5 ; i++) { LineChart.Data data = new LineChart.Data<>(i, Math.pow(2, i)); series.getData().add(data); } Chart lineChart = new LineChart(xAxis, yAxis, FXCollections.observableArrayList(series)); lineChart.setTitle("Power of 2"); Scene scene = new Scene(lineChart, 500, 500); URL cssURL = getClass().getResource("main.css"); if (cssURL == null) { cssURL = getClass().getResource("main.bss"); } scene.getStylesheets().add(cssURL.toExternalForm()); primaryStage.setScene(scene); primaryStage.show(); } }