Example #1
0
  private void initContent(GridPane pane) {

    pane.setGridLinesVisible(!true);
    pane.setHgap(20);
    pane.setVgap(10);
    pane.setPadding(new Insets(20));

    Label lblExcursions = new Label("Excursions:");
    Label lblHotels = new Label("Hotels");
    Label lblParticipants = new Label("Participants");

    pane.add(lblExcursions, 0, 0);
    pane.add(lblHotels, 1, 0);
    pane.add(lblParticipants, 2, 0);

    this.excursions = new ListView<Excursion>();
    this.excursions.setPrefSize(200, 200);
    this.excursions.setPrefHeight(200);
    pane.add(this.excursions, 0, 1);

    this.hotels = new ListView<>();
    this.hotels.setPrefSize(200, 200);
    this.hotels.setPrefHeight(200);
    pane.add(this.hotels, 1, 1);

    this.participants = new ListView<>();
    this.participants.setPrefSize(200, 200);
    pane.add(this.participants, 2, 1);

    Button btnClose = new Button("Close");
    pane.add(btnClose, 0, 2);
    btnClose.setOnAction(event -> this.controller.closeOnAction());
  }
Example #2
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    Random rand = new Random();

    GridPane layout = new GridPane();
    layout.setGridLinesVisible(true);
    layout.setAlignment(Pos.CENTER);
    layout.setVgap(2);
    layout.setHgap(2);
    layout.setPadding(new Insets(10, 10, 10, 10));

    int j = 0;
    for (int i = 0; i < 11; i++) {

      int newRandomNum = rand.nextInt((1 - 0) + 1) + 0;
      TextField number = new TextField();
      number.setText(Integer.toString(newRandomNum));

      if (i > 9) {
        if (j > 8) {
          break;
        } else {
          j++;
          i = 0;
        }
      }

      layout.add(number, j, i);
    }

    Scene scene = new Scene(layout, 300, 300);

    primaryStage.setScene(scene);
    primaryStage.show();
  }
  @Override
  public void start(Stage primaryStage) throws Exception {
    Label fnameLbl = new Label(Msg.get(this, "firstName"));
    TextField fnameFld = new TextField();
    Label lnameLbl = new Label(Msg.get(this, "lastName"));
    TextField lnameFld = new TextField();
    Button okBtn = new Button(Msg.get(this, "OK"));
    Button cancelBtn = new Button(Msg.get(this, "cancel"));

    // The OK button should fill its cell
    okBtn.setMaxWidth(Double.MAX_VALUE);

    // Create a GridPane and set its background color to lightgray
    GridPane root = new GridPane();
    root.setGridLinesVisible(true);
    root.setHgap(10);
    root.setVgap(5);
    root.setStyle(Msg.get(this, "style"));

    // Add children to teh GridPane
    root.addRow(0, fnameLbl, fnameFld, okBtn);
    root.addRow(1, lnameLbl, lnameFld, cancelBtn);

    Scene scene = new Scene(root);
    primaryStage.setScene(scene);
    primaryStage.setTitle(Msg.get(this, "title"));
    primaryStage.show();
  }
Example #4
0
  private void initContent(GridPane pane) {

    pane.setGridLinesVisible(!true);
    pane.setPadding(new Insets(20));
    pane.setHgap(10);
    pane.setVgap(10);

    Label names = new Label("Names:");
    pane.add(names, 0, 1);

    Label name = new Label("Name:");
    pane.add(name, 0, 3);

    this.names = new ListView<String>();
    pane.add(this.names, 1, 1, 1, 2);
    this.names.setPrefWidth(200);
    this.names.setPrefHeight(200);
    this.names.getItems().setAll(this.boyNames);
    // GridPane.setMargin(this.boyNames, new Insets(-25, 0, 0, 0));

    this.name = new TextField();
    pane.add(this.name, 1, 3, 1, 1);

    HBox box = new HBox(20);
    pane.add(box, 1, 0);
    this.namesGroup = new ToggleGroup();
    String[] gender = {"Boy", "Girl"};
    for (String s : gender) {
      RadioButton rb = new RadioButton();
      rb.setToggleGroup(this.namesGroup);
      rb.setText(s);
      box.getChildren().add(rb);
      rb.setSelected(true);
    }

    ChangeListener<Toggle> listener = (ov, oldValue, newValue) -> this.namesToggleSelected();
    this.namesGroup.selectedToggleProperty().addListener(listener);

    Button add_name = new Button("Add");
    pane.add(add_name, 4, 3);
    add_name.setOnAction(event -> this.add_name());
  }
Example #5
0
  public static StackPane showButtons() {

    StackPane rootNode = new StackPane();
    Scene scene = new Scene(rootNode, 800, 300);

    GridPane gp = new GridPane();
    ColumnConstraints column = new ColumnConstraints(400);
    RowConstraints row = new RowConstraints(300);
    gp.getColumnConstraints().add(column);
    gp.getRowConstraints().add(row);

    gp.setGridLinesVisible(true);

    Button bookTable = new Button("Book \n a \n table");
    Button roomService = new Button("Room service");

    bookTable.setPrefSize(400, 300);
    roomService.setPrefSize(400, 300);

    gp.add(bookTable, 0, 0);
    gp.add(roomService, 1, 0);

    rootNode.getChildren().add(gp);

    // ActionEvents for buttons

    bookTable.setOnAction(
        e -> {
          rootNode.getChildren().clear();
          rootNode.getChildren().add(BookATable.getNode());
        });

    roomService.setOnAction(
        e -> {
          rootNode.getChildren().clear();
        });

    return rootNode;
  }
Example #6
0
  public void checkResultScreen(String[] listOfImageAsk) {

    VBox vbox = new VBox(40);
    GridPane grid = new GridPane();
    grid.setGridLinesVisible(false);
    Image imgYes =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\yes.gif");
    ImageView imageViewYes = new ImageView(imgYes);
    Image imgNo =
        new Image(
            "file:C:\\Users\\emaktse\\Documents\\HITSA\\GIT Repository\\javaProject\\Images library\\no.gif");
    ImageView imageViewNo = new ImageView(imgNo);

    int i = 0;
    for (int j = 0; j < 7; j++) {
      for (int k = 0; k < 7; k++) {
        Image image = allImages[i];
        ImageView imageCheck = new ImageView(image);
        imageCheck.setId(i + ".gif");
        grid.add(imageCheck, k, j);
        i++;
      }
    }

    grid.setOnMouseClicked(
        e -> {
          ImageView imageViewSourceRef = (ImageView) e.getTarget();
          reactOnMouseClick(grid, listOfImageAsk, imgYes, imgNo, imageViewSourceRef);
        });

    Button tryAgain = new Button("Try again");
    grid.setAlignment(Pos.CENTER);
    vbox.getChildren().addAll(grid, tryAgain);
    vbox.setAlignment(Pos.CENTER);

    scene4 = new Scene(vbox, 1000, 800);
    window1.setScene(scene4);
  }
Example #7
0
  public GridPane drawInventory(int countX, int countY, int countSlots) {

    GridPane grid = new GridPane();

    // Grid inner-padding
    grid.setHgap(10);
    grid.setVgap(10);

    // Grid external-padding
    grid.setPadding(new Insets(20));

    // Make gridlines visible
    grid.setGridLinesVisible(true);

    for (int y = 0; y < countY; y++) {
      for (int x = 0; x < countX; x++) {
        if (countSlots > 0) {
          grid.add(drawSlot(50, 50, Color.ORANGE), x, y);
          countSlots--;
        }
      }
    }

    if (countSlots > 0) {
      System.err.println(
          "[INFO] drawInventory: "
              + "countSlot is greater than gridbounds ("
              + countX
              + ", "
              + countY
              + "). "
              + countSlots
              + " slots remaining!");
    }

    return grid;
  }
  public GridPaneSample() {

    VBox vbox = new VBox();

    // grid1 places the child by specifying the rows and columns in
    // GridPane.setContraints()
    Label grid1Caption =
        new Label(
            "The example below shows GridPane content placement by specifying rows and columns:");
    grid1Caption.setWrapText(true);
    GridPane grid1 = new GridPane();
    grid1.setHgap(4);
    grid1.setVgap(6);
    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    Label label = new Label("Name:");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("John Q. Public");
    GridPane.setConstraints(label, 1, 0, 2, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    label = new Label("Address:");
    GridPane.setConstraints(label, 0, 1);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("12345 Main Street, Some City, CA");
    GridPane.setConstraints(label, 1, 1, 5, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    vbox.getChildren().addAll(grid1Caption, grid1, new Separator());

    // grid2 places the child by influencing the rows and columns themselves
    // via GridRowInfo and GridColumnInfo. This grid uses the preferred
    // width/height and max/min width/height.
    Label grid2Caption =
        new Label(
            "The example below shows GridPane content placement by influencing the rows and columns themselves.");
    grid2Caption.setWrapText(true);
    grid2Caption.setWrapText(true);
    GridPane grid2 = new GridPane();
    grid2.setPadding(new Insets(18, 18, 18, 18));
    RowConstraints rowinfo = new RowConstraints(40, 40, 40);
    ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90);

    for (int i = 0; i <= 2; i++) {
      grid2.getRowConstraints().add(rowinfo);
    }

    for (int j = 0; j <= 2; j++) {
      grid2.getColumnConstraints().add(colinfo);
    }

    Label category = new Label("Category:");
    GridPane.setHalignment(category, HPos.RIGHT);
    Label categoryValue = new Label("Wines");
    Label company = new Label("Company:");
    GridPane.setHalignment(company, HPos.RIGHT);
    Label companyValue = new Label("Acme Winery");
    Label rating = new Label("Rating:");
    GridPane.setHalignment(rating, HPos.RIGHT);
    Label ratingValue = new Label("Excellent");

    ImageView imageView = new ImageView(ICON_48);
    GridPane.setHalignment(imageView, HPos.CENTER);

    // Place content
    GridPane.setConstraints(category, 0, 0);
    GridPane.setConstraints(categoryValue, 1, 0);
    GridPane.setConstraints(company, 0, 1);
    GridPane.setConstraints(companyValue, 1, 1);
    GridPane.setConstraints(imageView, 2, 1);
    GridPane.setConstraints(rating, 0, 2);
    GridPane.setConstraints(ratingValue, 1, 2);
    grid2
        .getChildren()
        .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue);

    vbox.getChildren().addAll(grid2Caption, grid2, new Separator());

    // grid3 places the child by influencing the rows and columns
    // via GridRowInfo and GridColumnInfo. This grid uses the percentages
    Label grid3Caption =
        new Label(
            "The example below shows GridPane content placement by influencing row and column percentages.  Also, grid lines are made visible in this example.  The lines can be helpful in debugging.");
    grid3Caption.setWrapText(true);
    GridPane grid3 = new GridPane();
    grid3.setPadding(new Insets(18, 18, 18, 18));
    grid3.setGridLinesVisible(true);
    RowConstraints rowinfo3 = new RowConstraints();
    rowinfo3.setPercentHeight(50);

    ColumnConstraints colInfo2 = new ColumnConstraints();
    colInfo2.setPercentWidth(25);

    ColumnConstraints colInfo3 = new ColumnConstraints();
    colInfo3.setPercentWidth(50);

    grid3.getRowConstraints().add(rowinfo3); // 2*50 percent
    grid3.getRowConstraints().add(rowinfo3);

    grid3.getColumnConstraints().add(colInfo2); // 25 percent
    grid3.getColumnConstraints().add(colInfo3); // 50 percent
    grid3.getColumnConstraints().add(colInfo2); // 25 percent

    Label condLabel = new Label(" Member Name:");
    GridPane.setHalignment(condLabel, HPos.RIGHT);
    GridPane.setConstraints(condLabel, 0, 0);
    Label condValue = new Label("MyName");
    GridPane.setMargin(condValue, new Insets(0, 0, 0, 10));
    GridPane.setConstraints(condValue, 1, 0);

    Label acctLabel = new Label("Member Number:");
    GridPane.setHalignment(acctLabel, HPos.RIGHT);
    GridPane.setConstraints(acctLabel, 0, 1);
    TextField textBox = new TextField("Your number");
    GridPane.setMargin(textBox, new Insets(10, 10, 10, 10));
    GridPane.setConstraints(textBox, 1, 1);

    Button button = new Button("Help");
    GridPane.setConstraints(button, 2, 1);
    GridPane.setMargin(button, new Insets(10, 10, 10, 10));
    GridPane.setHalignment(button, HPos.CENTER);

    GridPane.setConstraints(condValue, 1, 0);
    grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox);

    vbox.getChildren().addAll(grid3Caption, grid3);

    getChildren().add(vbox);
  }
Example #9
0
  // This adds the Gridpane to the Search page (displays all entrys in the database)
  public static void addSearchGrid(int loopLength) {

    GridPane grid = new GridPane();
    // padding from outer frame
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setStyle("-fx-border-color: black;");
    // Padding
    grid.setVgap(10);
    grid.setHgap(10);
    // Grid lines visible
    grid.setGridLinesVisible(true);
    grid.setMinSize(1050, 510);
    // grid.setAlignment(Pos.CENTER);

    int numCol = 0;

    for (int i = 0; i < loopLength; i++) {

      GridPane smallGrid = new GridPane();
      smallGrid.setPadding(new Insets(10, 10, 10, 10));
      smallGrid.setMinSize(510, 157);

      if (i < 5) {

        hotelContainer[i] = new GridPane();

        hotelContainer[i].setStyle("-fx-border-color: black;");
        hotelLabel[i] = new Label();
        addressLabel[i] = new Label();
        starsLabel[i] = new Label();
        //          	poolLabel[i] = new Label();
        //          	gymLabel[i] = new Label();
        //          	petsLabel[i] = new Label();
        //          	barLabel[i] = new Label();
        priceLabel[i] = new Label();

        // ny
        imgView[i] = new ImageView();
        imgView[i].setFitHeight(150);
        imgView[i].setFitWidth(120);
        smallGrid.setHalignment(imgView[i], HPos.LEFT);
        smallGrid.setColumnSpan(imgView[i], 1);
        smallGrid.setRowSpan(imgView[i], 6);

        // imgView[i].setStyle("-fx-border-color: black;");

        // hotelContainer[i].getChildren().addAll(hotelLabel [i], addressLabel [i],starsLabel[i],
        // poolLabel[i],gymLabel[i],petsLabel[i], barLabel[i],  priceLabel[i]);
        System.out.println("loopstart");
        // container.getChildren().addAll(hotelContainer[i]);

        // ny
        // smallGrid.add(imv, numCol, i);
        smallGrid.add(imgView[i], numCol, i);
        smallGrid.add(hotelLabel[i], numCol + 1, i + 1);
        smallGrid.add(addressLabel[i], numCol + 1, i + 2);
        smallGrid.add(starsLabel[i], numCol + 1, i + 3);
        //        	smallGrid.add(starsLabel[i], numCol+1, i+2);
        //        	smallGrid.add(starsLabel, numCol+1, i+3);
        smallGrid.add(priceLabel[i], numCol + 1, i + 4);

        grid.add(smallGrid, 0, i);
        System.out.println("numCol " + numCol);
        System.out.println("i " + i);

        // smallGrid.add(hotelContainer[i], 0, i);
        System.out.println("i= " + i);

        // container.setPrefHeight(156*6);//loopLength

        //	numCol++;

      } else if (i >= 5 && i <= 10) { // && i<=6

        hotelContainer[i] = new GridPane();
        //   			hotelContainer[i].setPrefHeight(156);
        //   			hotelContainer[i].setLayoutY(i*156);
        hotelContainer[i].setStyle("-fx-border-color: black;");
        hotelLabel[i] = new Label();
        // hotelLabel[i].setStyle("-fx-border-color: black;");
        addressLabel[i] = new Label();
        starsLabel[i] = new Label();
        //             	poolLabel[i] = new Label();
        //             	gymLabel[i] = new Label();
        //             	petsLabel[i] = new Label();
        //             	barLabel[i] = new Label();
        priceLabel[i] = new Label();
        priceLabel[i].setPadding(new Insets(2, 1, 1, 1));

        // ny

        imgView[i] = new ImageView();
        imgView[i].setFitHeight(150);
        imgView[i].setFitWidth(120);
        // Shadow on image
        // imgView[i].setStyle("-fx-effect: dropshadow( gaussian , gray, 1,1,1,1 )");
        smallGrid.setHalignment(imgView[i], HPos.LEFT);
        smallGrid.setColumnSpan(imgView[i], 1);
        smallGrid.setRowSpan(imgView[i], 6);

        // hotelContainer[i].getChildren().addAll(hotelLabel [i], addressLabel [i],starsLabel[i],
        // poolLabel[i],gymLabel[i],petsLabel[i], barLabel[i],  priceLabel[i]);
        System.out.println("loopstart");
        // container.getChildren().addAll(hotelContainer[i]);

        // ny
        smallGrid.add(imgView[i], numCol, i);

        // smallGrid.add(imv, numCol, i);

        smallGrid.add(hotelLabel[i], numCol + 1, i + 1);
        smallGrid.add(addressLabel[i], numCol + 1, i + 2);
        smallGrid.add(starsLabel[i], numCol + 1, i + 3);
        //           	smallGrid.add(starsLabel[i], numCol+1, i+2);
        //           	smallGrid.add(starsLabel, numCol+1, i+3);
        smallGrid.add(priceLabel[i], numCol + 1, i + 4);

        grid.add(smallGrid, 1, i - 5); // -4
        System.out.println("else if numCol =  " + numCol);
        System.out.println("else if i =  " + i);

        // smallGrid.add(hotelContainer[i], 0, i);
        System.out.println("i= " + i);

        // container.setPrefHeight(156*6);//loopLength

      } // else if statement ends
      numCol++;
    } // forloop ends

    sc = (ScrollPane) Main.scene5.lookup("#scroll");
    sc.setContent(grid);
    sc.setPadding(new Insets(30, 0, 0, 40));
  } // method ends
Example #10
0
File: Main.java Project: 8CAKE/ALE
  @Override
  public void start(Stage primaryStage) throws Exception {

    try {
      screenSize = Screen.getPrimary().getVisualBounds();
      width = screenSize.getWidth(); // gd.getDisplayMode().getWidth();
      height = screenSize.getHeight(); // gd.getDisplayMode().getHeight();
    } catch (Exception excep) {
      System.out.println("<----- Exception in  Get Screen Size ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    try {
      dbCon =
          DriverManager.getConnection(
              "jdbc:mysql://192.168.1.6:3306/ale", "Root", "oqu#$XQgHFzDj@1MGg1G8");
      estCon = true;
    } catch (SQLException sqlExcep) {
      System.out.println("<----- SQL Exception in Establishing Database Connection ----->");
      sqlExcep.printStackTrace();
      System.out.println("<---------->\n");
    }

    xmlParser.generateUserInfo();
    superUser = xmlParser.getSuperUser();

    // ----------------------------------------------------------------------------------------------------> Top Panel Start

    closeBtn = new Button("");
    closeBtn.getStyleClass().add("systemBtn");
    closeBtn.setOnAction(
        e -> {
          systemClose();
        });

    minimizeBtn = new Button("");
    minimizeBtn.getStyleClass().add("systemBtn");
    minimizeBtn.setOnAction(
        e -> {
          primaryStage.setIconified(true);
        });

    miscContainer = new HBox();

    calcBtn = new Button();
    calcBtn.getStyleClass().addAll("calcBtn");
    calcBtn.setOnAction(
        e -> {
          calculator calculator = new calculator();
          scientificCalculator scientificCalculator = new scientificCalculator();
          calculator.start(calculatorName);
        });

    miscContainer.getChildren().add(calcBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------------> Top Panel End

    // ----------------------------------------------------------------------------------------------> Navigation Panel Start

    Line initDivider = new Line();
    initDivider.setStartX(0.0f);
    initDivider.setEndX(205.0f);
    initDivider.setStroke(Color.GRAY);

    // <----- Dashboard ----->
    dashboardToolTip = new Tooltip("Dashboard");

    dashboardBtn = new Button("");
    dashboardBtn.getStyleClass().add("dashboardBtn");
    dashboardBtn.setTooltip(dashboardToolTip);
    dashboardBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(dashBoardBase);
        });

    // <----- Profile ----->
    profileToolTip = new Tooltip("Profile");

    profileBtn = new Button();
    profileBtn.getStyleClass().add("profileBtn");
    profileBtn.setTooltip(profileToolTip);
    profileBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(profilePanel);
        });

    // <----- Courses ----->
    courseToolTip = new Tooltip("Courses");

    coursesBtn = new Button("");
    coursesBtn.getStyleClass().add("coursesBtn");
    coursesBtn.setTooltip(courseToolTip);
    coursesBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(coursesPanel);
          // miscContainer.getChildren().addAll(watchVidBtn);
          coursesPanel.setContent(coursesGridPanel);
        });

    Line mainDivider = new Line();
    mainDivider.setStartX(0.0f);
    mainDivider.setEndX(205.0f);
    mainDivider.setStroke(Color.GRAY);

    // <----- Simulations ----->
    simsToolTip = new Tooltip("Simulations");

    simsBtn = new Button();
    simsBtn.getStyleClass().add("simsBtn");
    simsBtn.setTooltip(simsToolTip);
    simsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(simsPanel);
          simsPanel.setContent(simsGridPanel);
        });

    // <----- Text Editor ----->
    textEditorToolTip = new Tooltip("Text Editor");

    textEditorBtn = new Button();
    textEditorBtn.getStyleClass().add("textEditorBtn");
    textEditorBtn.setTooltip(textEditorToolTip);
    textEditorBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(textEditorPanel);
          miscContainer.getChildren().addAll(saveDocBtn);
        });

    Line toolsDivider = new Line();
    toolsDivider.setStartX(0.0f);
    toolsDivider.setEndX(205.0f);
    toolsDivider.setStroke(Color.GRAY);

    // <----- Wolfram Alpha ----->
    wolframToolTip = new Tooltip("Wolfram Alpha");

    wolframBtn = new Button();
    wolframBtn.getStyleClass().add("wolframBtn");
    wolframBtn.setTooltip(wolframToolTip);
    wolframBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wolframPanel);
        });

    // <----- Wikipedia ----->
    wikipediaToolTip = new Tooltip();

    wikipediaBtn = new Button();
    wikipediaBtn.getStyleClass().add("wikipediaBtn");
    wikipediaBtn.setTooltip(wikipediaToolTip);
    wikipediaBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(wikipediaPanel);
        });

    Line sitesDivider = new Line();
    sitesDivider.setStartX(0.0f);
    sitesDivider.setEndX(205.0f);
    sitesDivider.setStroke(Color.GRAY);

    // <----- Settings ----->
    settingsToolTip = new Tooltip("Settings");

    settingsBtn = new Button();
    settingsBtn.getStyleClass().add("settingsBtn");
    settingsBtn.setTooltip(settingsToolTip);
    settingsBtn.setOnAction(
        e -> {
          resetBtns();
          rootPane.setCenter(settingsPanel);
        });

    leftPanel = new VBox(0);
    // leftPanel.setPrefWidth(1);
    leftPanel.getStyleClass().add("leftPane");
    leftPanel
        .getChildren()
        .addAll(
            initDivider,
            dashboardBtn,
            profileBtn,
            coursesBtn,
            mainDivider,
            simsBtn,
            textEditorBtn,
            toolsDivider,
            wolframBtn,
            wikipediaBtn,
            sitesDivider,
            settingsBtn);

    topPanel = new HBox(1);
    topPanel.getStyleClass().add("topPanel");
    topPanel.setPrefWidth(width);
    topPanel.setAlignment(Pos.CENTER_RIGHT);
    topPanel.setPadding(new Insets(0, 0, 0, 0));
    topPanel.getChildren().addAll(miscContainer, minimizeBtn, closeBtn);

    // ------------------------------------------------------------------------------------------------> Navigation Panel End

    // -----------------------------------------------------------------------------------------------> Dashboard Pane Start

    final WebView webVid = new WebView();
    final WebEngine webVidEngine = webVid.getEngine();
    webVid.setPrefHeight(860);
    webVid.setPrefWidth(width - 118);
    webVidEngine.loadContent("");

    final NumberAxis xAxis = new NumberAxis();
    final NumberAxis yAxis = new NumberAxis();
    xAxis.setLabel("Day");
    yAxis.setLabel("Score");
    final LineChart<Number, Number> lineChart = new LineChart<Number, Number>(xAxis, yAxis);

    lineChart.setTitle("Line Chart");
    XYChart.Series<Number, Number> series = new XYChart.Series<Number, Number>();
    series.setName("My Data");

    // populating the series with data
    series.getData().add(new XYChart.Data<Number, Number>(0.25, 36));
    series.getData().add(new XYChart.Data<Number, Number>(1, 23));
    series.getData().add(new XYChart.Data<Number, Number>(2, 114));
    series.getData().add(new XYChart.Data<Number, Number>(3, 15));
    series.getData().add(new XYChart.Data<Number, Number>(4, 124));
    lineChart.getData().add(series);
    lineChart.setPrefWidth(400);
    lineChart.setPrefHeight(300);
    lineChart.setLegendVisible(false);

    chatRoomField = new TextField();
    chatRoomField.getStyleClass().add("textField");
    chatRoomField.setPromptText("Enter Chat Room");
    chatRoomField.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              chatRoom = chatRoomField.getText();
              client.connect(messageArea, messageInputArea, superUser, chatRoom);
            }
          }
        });

    messageArea = new TextArea();
    messageArea.getStyleClass().add("textArea");
    messageArea.setWrapText(true);
    messageArea.setPrefHeight(740);
    messageArea.setEditable(false);

    messageInputArea = new TextArea();
    messageInputArea.getStyleClass().add("textArea");
    messageInputArea.setWrapText(true);
    messageInputArea.setPrefHeight(100);
    messageInputArea.setPromptText("Enter Message");
    messageInputArea.setOnKeyPressed(
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              client.send(messageArea, messageInputArea, superUser, chatRoom);
              event.consume();
            }
          }
        });

    chatBox = new VBox();
    chatBox.setPrefWidth(250);
    chatBox.setMaxWidth(250);
    chatBox.getStyleClass().add("chatBox");
    chatBox.getChildren().addAll(chatRoomField, messageArea, messageInputArea);

    // client.test(messageArea, messageInputArea);

    dashboardGridPanel = new GridPane();
    dashboardGridPanel.getStyleClass().add("gridPane");
    dashboardGridPanel.setVgap(5);
    dashboardGridPanel.setHgap(5);
    dashboardGridPanel.setGridLinesVisible(false);
    dashboardGridPanel.setPrefWidth(width - 430);
    dashboardGridPanel.setPrefHeight(860);

    dashboardGridPanel.setColumnIndex(lineChart, 0);
    dashboardGridPanel.setRowIndex(lineChart, 0);
    dashboardGridPanel.getChildren().addAll(lineChart);

    dashboardPanel = new ScrollPane();
    dashboardPanel.getStyleClass().add("scrollPane");
    dashboardPanel.setPrefWidth(width - 400);
    dashboardPanel.setPrefHeight(860);
    dashboardPanel.setContent(dashboardGridPanel);

    dashBoardBase = new HBox();
    dashBoardBase.setPrefWidth(width - (leftPanel.getWidth() + chatBox.getWidth()));
    dashBoardBase.setPrefHeight(860);
    dashBoardBase.getChildren().addAll(dashboardPanel, chatBox);

    // -------------------------------------------------------------------------------------------------> Dashboard Pane End

    // -------------------------------------------------------------------------------------------------> Profile Pane Start

    profilePictureBtn = new Button();
    profilePictureBtn.getStyleClass().addAll("profilePictureBtn");

    String profileUserName = xmlParser.getSuperUser();

    String profileEmail = xmlParser.getEmail();
    String profileAge = xmlParser.getAge();
    String profileSchool = xmlParser.getSchool();
    String profileCountry = "";
    String profileCity = "";

    userNameLbl = new Label(profileUserName);
    userNameLbl.getStyleClass().add("profileLbl");
    userNameLbl.setAlignment(Pos.CENTER);

    emailLbl = new Label(profileEmail);
    emailLbl.getStyleClass().add("profileLbl");

    ageLbl = new Label(profileAge);
    ageLbl.getStyleClass().add("profileLbl");

    schoolLbl = new Label(profileSchool);
    schoolLbl.getStyleClass().add("profileLbl");

    profileGridPanel = new GridPane();
    profileGridPanel.getStyleClass().add("gridPane");
    profileGridPanel.setVgap(5);
    profileGridPanel.setHgap(5);
    profileGridPanel.setGridLinesVisible(false);
    profileGridPanel.setPrefWidth(width - 208);
    profileGridPanel.setPrefHeight(860);
    profileGridPanel.setAlignment(Pos.TOP_CENTER);

    profileGridPanel.setRowIndex(profilePictureBtn, 0);
    profileGridPanel.setColumnIndex(profilePictureBtn, 0);
    profileGridPanel.setRowIndex(userNameLbl, 1);
    profileGridPanel.setColumnIndex(userNameLbl, 0);
    profileGridPanel.setRowIndex(emailLbl, 2);
    profileGridPanel.setColumnIndex(emailLbl, 0);
    profileGridPanel.setRowIndex(ageLbl, 3);
    profileGridPanel.setColumnIndex(ageLbl, 0);
    profileGridPanel.setRowIndex(schoolLbl, 4);
    profileGridPanel.setColumnIndex(schoolLbl, 0);
    profileGridPanel
        .getChildren()
        .addAll(profilePictureBtn, userNameLbl, emailLbl, ageLbl, schoolLbl);

    profilePanel = new ScrollPane();
    profilePanel.getStyleClass().add("scrollPane");
    profilePanel.setContent(profileGridPanel);

    // ---------------------------------------------------------------------------------------------------> Profile Pane End

    // -------------------------------------------------------------------------------------------------> Courses Pane Start

    String course = "";

    // Media media = new Media("media.mp4");

    // mediaPlayer = new MediaPlayer(media);
    // mediaPlayer.setAutoPlay(true);

    // mediaView = new MediaView(mediaPlayer);

    watchVidBtn = new Button("Watch Video");
    watchVidBtn.getStyleClass().add("btn");
    watchVidBtn.setOnAction(
        e -> {

          // coursesPanel.setContent(mediaView);
        });

    chemistryBtn = new Button();
    chemistryBtn.getStyleClass().add("chemistryBtn");
    chemistryBtn.setOnAction(
        e -> {
          displayCourse("chemistry");
        });

    physicsBtn = new Button();
    physicsBtn.getStyleClass().add("physicsBtn");
    physicsBtn.setOnAction(
        e -> {
          displayCourse("physics");
        });

    mathsBtn = new Button();
    mathsBtn.getStyleClass().add("mathsBtn");

    bioBtn = new Button();
    bioBtn.getStyleClass().add("bioBtn");
    bioBtn.setOnAction(
        e -> {
          rootPane.setCenter(biologyCourse.biologyPane());
        });

    // Course Web View
    try {
      courseView = new WebView();
      courseWebEngine = courseView.getEngine();
      courseView.setPrefHeight(860);
      courseView.setPrefWidth(width - 208);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Course Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    coursesGridPanel = new GridPane();
    coursesGridPanel.getStyleClass().add("gridPane");
    coursesGridPanel.setVgap(5);
    coursesGridPanel.setHgap(5);
    coursesGridPanel.setGridLinesVisible(false);
    coursesGridPanel.setPrefWidth(width - 208);
    coursesGridPanel.setPrefHeight(860);

    coursesGridPanel.setRowIndex(chemistryBtn, 1);
    coursesGridPanel.setColumnIndex(chemistryBtn, 1);
    coursesGridPanel.setRowIndex(physicsBtn, 1);
    coursesGridPanel.setColumnIndex(physicsBtn, 2);
    coursesGridPanel.setRowIndex(mathsBtn, 1);
    coursesGridPanel.setColumnIndex(mathsBtn, 3);
    coursesGridPanel.setRowIndex(bioBtn, 1);
    coursesGridPanel.setColumnIndex(bioBtn, 4);
    coursesGridPanel.getChildren().addAll(chemistryBtn, physicsBtn, mathsBtn, bioBtn);

    coursesPanel = new ScrollPane();
    coursesPanel.getStyleClass().add("scrollPane");
    coursesPanel.setPrefWidth(width - 118);
    coursesPanel.setPrefHeight(860);
    coursesPanel.setContent(coursesGridPanel);

    // ---------------------------------------------------------------------------------------------------> Courses Pane End

    // ---------------------------------------------------------------------------------------------> Simulations Pane Start
    final WebView browser = new WebView();
    final WebEngine webEngine = browser.getEngine();
    browser.setPrefHeight(860);
    browser.setPrefWidth(width - 208);

    /*
    File phetImageFile = new File("img/styleDark/poweredByPHET.png");
    String phetImageURL = phetImageFile.toURI().toURL().toString();
    Image phetImage = new Image(phetImageURL, false);
    */

    final ImageView phetImageView = new ImageView();
    final Image phetImage =
        new Image(Main.class.getResourceAsStream("img/styleDark/poweredByPHET.png"));
    phetImageView.setImage(phetImage);

    Label motionLbl = new Label("Motion");
    motionLbl.getStyleClass().add("lbl");

    forcesAndMotionBtn = new Button();
    forcesAndMotionBtn.getStyleClass().add("forcesAndMotionBtn");
    forcesAndMotionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    balancingActBtn = new Button();
    balancingActBtn.getStyleClass().add("balancingActBtn");
    balancingActBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balancing-act/latest/balancing-act_en.html");
          simsPanel.setContent(browser);
        });

    energySkateParkBtn = new Button();
    energySkateParkBtn.getStyleClass().add("energySkateParkBtn");
    energySkateParkBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/energy-skate-park-basics/latest/"
                  + "energy-skate-park-basics_en.html");
          simsPanel.setContent(browser);
        });

    balloonsAndStaticElectricityBtn = new Button();
    balloonsAndStaticElectricityBtn.getStyleClass().add("balloonsAndStaticElectricityBtn");
    balloonsAndStaticElectricityBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/balloons-and-static-electricity/latest/"
                  + "balloons-and-static-electricity_en.html");
          simsPanel.setContent(browser);
        });

    buildAnAtomBtn = new Button();
    buildAnAtomBtn.getStyleClass().add("buildAnAtomBtn");
    buildAnAtomBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/build-an-atom/latest/build-an-atom_en.html");
          simsPanel.setContent(browser);
        });

    colorVisionBtn = new Button();
    colorVisionBtn.getStyleClass().add("colorVisionBtn");
    colorVisionBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/color-vision/latest/color-vision_en.html");
          simsPanel.setContent(browser);
        });

    Label soundAndWavesLbl = new Label("Sound and Waves");
    soundAndWavesLbl.getStyleClass().add("lbl");

    wavesOnAStringBtn = new Button();
    wavesOnAStringBtn.getStyleClass().add("wavesOnAStringBtn");
    wavesOnAStringBtn.setOnAction(
        e -> {
          webEngine.load(
              "https://phet.colorado.edu/sims/html/wave-on-a-string/latest/wave-on-a-string_en.html");
          simsPanel.setContent(browser);
        });

    /*
    motionSimsFlowPane = new FlowPane();
    motionSimsFlowPane.getStyleClass().add("flowPane");
    motionSimsFlowPane.setVgap(5);
    motionSimsFlowPane.setHgap(5);
    motionSimsFlowPane.setAlignment(Pos.TOP_LEFT);
    motionSimsFlowPane.getChildren().addAll(forcesAndMotionBtn, balancingActBtn, energySkateParkBtn,
            buildAnAtomBtn, colorVisionBtn, wavesOnAStringBtn);


    soundAndWavesFlowPane = new FlowPane();
    soundAndWavesFlowPane.getStyleClass().add("flowPane");
    soundAndWavesFlowPane.setVgap(5);
    soundAndWavesFlowPane.setHgap(5);
    soundAndWavesFlowPane.setAlignment(Pos.TOP_LEFT);
    soundAndWavesFlowPane.getChildren().addAll(wavesOnAStringBtn);


    simsBox = new VBox();
    simsBox.getStyleClass().add("vbox");
    simsBox.setPrefHeight(height);
    simsBox.setPrefWidth(width);
    simsBox.getChildren().addAll(motionLbl, motionSimsFlowPane, soundAndWavesLbl, soundAndWavesFlowPane);
    */

    simsGridPanel = new GridPane();
    simsGridPanel.getStyleClass().add("gridPane");
    simsGridPanel.setVgap(5);
    simsGridPanel.setHgap(5);
    simsGridPanel.setGridLinesVisible(false);
    simsGridPanel.setPrefWidth(width - 208);
    simsGridPanel.setPrefHeight(860);

    simsGridPanel.setRowIndex(phetImageView, 0);
    simsGridPanel.setColumnIndex(phetImageView, 4);

    simsGridPanel.setRowIndex(motionLbl, 0);
    simsGridPanel.setColumnIndex(motionLbl, 0);
    simsGridPanel.setRowIndex(forcesAndMotionBtn, 1);
    simsGridPanel.setColumnIndex(forcesAndMotionBtn, 0);
    simsGridPanel.setRowIndex(balancingActBtn, 1);
    simsGridPanel.setColumnIndex(balancingActBtn, 1);
    simsGridPanel.setRowIndex(energySkateParkBtn, 1);
    simsGridPanel.setColumnIndex(energySkateParkBtn, 2);
    simsGridPanel.setRowIndex(buildAnAtomBtn, 1);
    simsGridPanel.setColumnIndex(buildAnAtomBtn, 3);
    simsGridPanel.setRowIndex(colorVisionBtn, 1);
    simsGridPanel.setColumnIndex(colorVisionBtn, 4);

    simsGridPanel.setRowIndex(soundAndWavesLbl, 2);
    simsGridPanel.setColumnIndex(soundAndWavesLbl, 0);
    simsGridPanel.setColumnSpan(soundAndWavesLbl, 4);
    simsGridPanel.setRowIndex(wavesOnAStringBtn, 3);
    simsGridPanel.setColumnIndex(wavesOnAStringBtn, 0);

    simsGridPanel
        .getChildren()
        .addAll(
            phetImageView,
            motionLbl,
            forcesAndMotionBtn,
            balancingActBtn,
            energySkateParkBtn,
            buildAnAtomBtn,
            colorVisionBtn,
            soundAndWavesLbl,
            wavesOnAStringBtn);

    simsPanel = new ScrollPane();
    simsPanel.getStyleClass().add("scrollPane");
    simsPanel.setContent(simsGridPanel);

    // -----------------------------------------------------------------------------------------------> Simulations Pane End

    // ---------------------------------------------------------------------------------------------> Text Editor Pane Start

    htmlEditor = new HTMLEditor();
    htmlEditor.setPrefHeight(860);
    htmlEditor.setPrefWidth(width - 208);

    // Prevents Scroll on Space Pressed
    htmlEditor.addEventFilter(
        KeyEvent.KEY_PRESSED,
        new EventHandler<KeyEvent>() {
          @Override
          public void handle(KeyEvent event) {
            if (event.getEventType() == KeyEvent.KEY_PRESSED) {
              if (event.getCode() == KeyCode.SPACE) {
                event.consume();
              }
            }
          }
        });

    XWPFDocument document = new XWPFDocument();
    XWPFParagraph tmpParagraph = document.createParagraph();
    XWPFRun tmpRun = tmpParagraph.createRun();

    saveDocBtn = new Button();
    saveDocBtn.getStyleClass().add("btn");
    saveDocBtn.setText("Save");
    saveDocBtn.setOnAction(
        e -> {
          tmpRun.setText(tools.stripHTMLTags(htmlEditor.getHtmlText()));
          tmpRun.setFontSize(12);
          saveDocument(document, primaryStage);
        });

    textEditorPanel = new ScrollPane();
    textEditorPanel.getStyleClass().add("scrollPane");
    textEditorPanel.setContent(htmlEditor);

    // -----------------------------------------------------------------------------------------------> Text Editor Pane End

    // -------------------------------------------------------------------------------------------------> Wolfram Pane Start

    Boolean wolframActive = false;
    try {
      final WebView wolframWeb = new WebView();
      wolframWeb.getStyleClass().add("webView");
      final WebEngine wolframWebEngine = wolframWeb.getEngine();
      wolframWeb.setPrefHeight(860);
      wolframWeb.setPrefWidth(width - 208);
      if (wolframActive == false) {
        wolframWebEngine.load("http://www.wolframalpha.com/");
        wolframActive = true;
      }
      wolframPanel = new ScrollPane();
      wolframPanel.setContent(wolframWeb);
    } catch (Exception excep) {
      System.out.println("<----- Exception in Wolfram Alpha Web ----->");
      excep.printStackTrace();
      System.out.println("<---------->\n");
    }

    // ---------------------------------------------------------------------------------------------------> Wolfram Pane End

    // ------------------------------------------------------------------------------------------------> Wikipedia Pane Start

    Boolean wikipediaActive = false;
    try {
      final WebView wikipediaWeb = new WebView();
      wikipediaWeb.getStyleClass().add("scrollPane");
      wikipediaWebEngine = wikipediaWeb.getEngine();
      wikipediaWeb.setPrefHeight(860);
      wikipediaWeb.setPrefWidth(width - 208);
      if (wikipediaActive == false) {
        wikipediaWebEngine.load("https://en.wikipedia.org/wiki/Main_Page");
        wikipediaActive = true;
      }
      wikipediaPanel = new ScrollPane();
      wikipediaPanel.setContent(wikipediaWeb);
    } catch (Exception e) {
      e.printStackTrace();
    }

    // --------------------------------------------------------------------------------------------------> Wikipedia Pane End

    // -------------------------------------------------------------------------------------------------> Settings Pane Start

    settingsGridPanel = new GridPane();
    settingsGridPanel.getStyleClass().add("gridPane");
    settingsGridPanel.setPrefWidth(width - 208);
    settingsGridPanel.setPrefHeight(height);
    settingsGridPanel.setVgap(5);
    settingsGridPanel.setHgap(5);

    settingsPanel = new ScrollPane();
    settingsPanel.getStyleClass().add("scrollPane");
    settingsPanel.setContent(settingsGridPanel);

    // ---------------------------------------------------------------------------------------------------> Settings Pane End
    rootPane = new BorderPane();
    rootPane.setLeft(leftPanel);
    rootPane.setTop(topPanel);
    rootPane.setCenter(dashBoardBase);
    rootPane.getStyleClass().add("rootPane");
    rootPane.getStylesheets().add(Main.class.getResource("css/styleDark.css").toExternalForm());

    programWidth = primaryStage.getWidth();
    programHeight = primaryStage.getHeight();

    primaryStage.setTitle("ALE");
    primaryStage.initStyle(StageStyle.UNDECORATED);
    primaryStage
        .getIcons()
        .add(new javafx.scene.image.Image(Main.class.getResourceAsStream("img/aleIcon.png")));
    primaryStage.setScene(new Scene(rootPane, width, height));
    primaryStage.show();
  }
Example #11
-1
  @Override
  public void start(Stage primaryStage) {
    primaryStage.setTitle("JavaFX layouts samples");

    Tab hboxTab = new Tab();
    hboxTab.setText("HBox");
    hboxTab.setClosable(false);
    hboxLayout.setBackground(createBackground(Color.LIGHTGREEN));
    hboxTab.setContent(hboxLayout);

    Tab vboxTab = new Tab();
    vboxTab.setText("VBox");
    vboxTab.setClosable(false);
    vboxLayout.setBackground(createBackground(Color.ORANGE));
    vboxTab.setContent(vboxLayout);

    Tab flowPaneTab = new Tab();
    flowPaneTab.setText("FlowPane");
    flowPaneTab.setClosable(false);
    flowLayout.setBackground(createBackground(Color.LIGHTSKYBLUE));
    flowPaneTab.setContent(flowLayout);

    Tab gridPaneTab = new Tab("GridPane");
    gridPaneTab.setClosable(false);
    gridLayout.setBackground(createBackground(Color.LIGHTCORAL));
    gridLayout.setGridLinesVisible(true);
    gridPaneTab.setContent(gridLayout);

    Tab borderPaneTab = new Tab();
    borderPaneTab.setText("BorderPane");
    borderPaneTab.setClosable(false);
    borderLayout.setBackground(createBackground(Color.LIGHTYELLOW));
    borderPaneTab.setContent(borderLayout);

    Tab stackPaneTab = new Tab();
    stackPaneTab.setText("StackPane");
    stackPaneTab.setClosable(false);
    stackLayout.setBackground(createBackground(Color.YELLOW));
    stackPaneTab.setContent(stackLayout);

    Tab tilePaneTab = new Tab("TilePane");
    tilePaneTab.setClosable(false);
    tileLayout.setBackground(createBackground(Color.LIGHTGOLDENRODYELLOW));
    tilePaneTab.setContent(tileLayout);

    updateChildren(false);
    TabPane tabPane = new TabPane();
    tabPane
        .getTabs()
        .addAll(
            hboxTab, vboxTab, flowPaneTab, gridPaneTab, borderPaneTab, stackPaneTab, tilePaneTab);

    VBox optionsPanel = new VBox();
    CheckBox componentType = new CheckBox("Use Buttons instead of Rectangles");
    componentType
        .selectedProperty()
        .addListener((observable, oldValue, newValue) -> updateChildren(newValue));
    optionsPanel.getChildren().add(componentType);
    optionsPanel.setPadding(new Insets(10));

    BorderPane mainLayout = new BorderPane();
    mainLayout.setCenter(tabPane);
    mainLayout.setLeft(optionsPanel);

    // show the generated scene graph
    Scene scene = new Scene(mainLayout);
    primaryStage.setScene(scene);
    primaryStage.show();
  }