Ejemplo n.º 1
0
  private void CreateForm() throws SQLException {
    box = new VBox();
    HBox Hbox = new HBox();
    Hbox.setAlignment(Pos.CENTER);
    Hbox.getChildren().add(box);
    Hbox.setLayoutX(width / 2 - Hbox.getWidth() / 2);
    root.getChildren().add(Hbox);
    root.getChildren().add(box);

    // final Label logn=new Label("For connecting to the database press the button ");
    final Button ok = new Button("Connect to server");

    box.setAlignment(Pos.TOP_CENTER);
    box.maxWidth(width);
    box.minWidth(width);

    log = "root";
    psswrd = "0000";

    Hbox.setLayoutX(width / 2 - 135);
    Hbox.setLayoutY(height / 2 - 80);

    final Button ok2 = new Button("Connect to server");
    ok2.setOnAction(event -> System.out.println("Button was pressed."));

    ok.setOnAction(
        event -> {
          try {
            System.out.println("Button was pressed.");
            db = new MySQLAccess("univer", log, psswrd);
            // logn.setVisible(false);
            ok.setVisible(false);
            /*final Button qq=new Button("qq");
            ok.setLayoutX(width / 2 - 80);
            ok.setLayoutY(height / 2 - 80);
            box.setAlignment(Pos.TOP_CENTER);
            box.maxWidth(width);
            box.minWidth(width);
            box.getChildren().addAll(qq);*/
            OutputInformation();
            /* final Button qq=new Button("qq");
            ok.setLayoutX(width / 2 - 80);
            ok.setLayoutY(height / 2 - 80);
            box.setAlignment(Pos.TOP_CENTER);
            box.maxWidth(width);
            box.minWidth(width);
            box.getChildren().addAll(qq);*/
          } catch (ClassNotFoundException e) {
            System.out.println(e);
          } catch (SQLException e) {
            System.out.println(e);
          }
        });

    box.getChildren().add(ok2);
  }