Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. public GridPane addGridPane() {
  2.     GridPane grid = new GridPane();
  3.     grid.setHgap(10);
  4.     grid.setVgap(10);
  5.     grid.setPadding(new Insets(0, 10, 0, 10));
  6.  
  7.     // Category in column 2, row 1
  8.     Text category = new Text("Sales:");
  9.     category.setFont(Font.font("Arial", FontWeight.BOLD, 20));
  10.     grid.add(category, 1, 0);
  11.  
  12.     // Title in column 3, row 1
  13.     Text chartTitle = new Text("Current Year");
  14.     chartTitle.setFont(Font.font("Arial", FontWeight.BOLD, 20));
  15.     grid.add(chartTitle, 2, 0);
  16.  
  17.     // Subtitle in columns 2-3, row 2
  18.     Text chartSubtitle = new Text("Goods and Services");
  19.     grid.add(chartSubtitle, 1, 1, 2, 1);
  20.  
  21.     // House icon in column 1, rows 1-2
  22.     ImageView imageHouse = new ImageView(
  23.       new Image(LayoutSample.class.getResourceAsStream("graphics/house.png")));
  24.     grid.add(imageHouse, 0, 0, 1, 2);
  25.  
  26.     // Left label in column 1 (bottom), row 3
  27.     Text goodsPercent = new Text("Goods\n80%");
  28.     GridPane.setValignment(goodsPercent, VPos.BOTTOM);
  29.     grid.add(goodsPercent, 0, 2);
  30.  
  31.     // Chart in columns 2-3, row 3
  32.     ImageView imageChart = new ImageView(
  33.      new Image(LayoutSample.class.getResourceAsStream("graphics/piechart.png")));
  34.     grid.add(imageChart, 1, 2, 2, 1);
  35.  
  36.     // Right label in column 4 (top), row 3
  37.     Text servicesPercent = new Text("Services\n20%");
  38.     GridPane.setValignment(servicesPercent, VPos.TOP);
  39.     grid.add(servicesPercent, 3, 2);
  40.  
  41.     return grid;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement