public GridPositionCalc build() {
   int width = (int) ((gridView.getPrefHeight()));
   int x = (int) ((gridView.getPrefWidth() / 2) - width / 2);
   initRect(width, x);
   initLabels(width, x);
   initLabelText(x, width);
   return new GridPositionCalc(x, paddingTop, width);
 }
  @Override
  public void initialize(URL location, ResourceBundle resources) {
    // TODO Auto-generated method stub
    w = drawPane.getPrefWidth();
    h = drawPane.getPrefHeight();

    Algorithm = new Algorithm(w, h);
    init();
    loop();
    event();
  }
 public double[] getContainerSize() {
   return new double[] {pane.getPrefWidth(), pane.getPrefHeight()};
 }
Пример #4
0
  @Override
  public void start(Stage stage) {
    LoginFX.stage = stage;
    stage.setTitle("SGAP - Login");
    pane = new Pane();
    pane.setPrefSize(400, 120);
    pane.setStyle(
        "-fx-background-color:linear-gradient(from 0% 0% to 100% 100%, silver 0%, gold 100%);");

    tfLogin = new TextField();
    tfLogin.setPromptText("Digite aqui seu login");
    tfLogin.setPrefSize(200, tfLogin.getFont().getSize());
    tfSenha = new PasswordField();
    tfSenha.setPromptText("Digite aqui a senha");
    tfSenha.setPrefSize(200, tfSenha.getFont().getSize());
    tfSenha.setOnKeyPressed(
        new EventHandler<KeyEvent>() {

          @Override
          public void handle(KeyEvent event) {
            if (event.getCode() == KeyCode.ENTER) {
              botaoLogar();
            }
          }
        });

    bEntrar = new Button("Entrar");
    bEntrar.setPrefSize(100, bEntrar.getFont().getSize() + 5);
    bEntrar.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            botaoLogar();
          }
        });
    bSair = new Button("Sair");
    bSair.setPrefSize(100, bSair.getFont().getSize() + 5);
    bSair.setOnAction(
        new EventHandler<ActionEvent>() {

          @Override
          public void handle(ActionEvent event) {
            botaoSair();
          }
        });

    tfLogin.setLayoutX(
        (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    tfSenha.setLayoutX(
        (pane.getPrefWidth() - 1.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    bEntrar.setLayoutX(
        (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    bSair.setLayoutX(
        (pane.getPrefWidth() + 3.5 * bEntrar.getPrefWidth() - tfLogin.getPrefWidth()) / 2);
    tfLogin.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20);
    tfSenha.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20);
    bEntrar.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 - 20);
    bSair.setLayoutY((pane.getPrefHeight() - tfLogin.getPrefHeight()) / 2 + 20);

    pane.getChildren().addAll(tfLogin, tfSenha, bEntrar, bSair);
    Scene cena = new Scene(pane);
    stage.setScene(cena);
    stage.show();
  }