Esempio n. 1
0
  @Override
  public void start(Stage primaryStage) throws Exception {
    GridPane grid = new GridPane();
    grid.setAlignment(Pos.CENTER);
    grid.setVgap(10);
    grid.setHgap(10);
    grid.setPadding(new Insets(25, 25, 25, 25));

    Scene sc = new Scene(grid, 500, 500);

    String css = Main.class.getResource("Login.css").toExternalForm();
    //        System.out.println(css);
    sc.getStylesheets().add(css);

    Text scenetitle = new Text("Welcome");
    //        scenetitle.setFont(Font.font("Tahoma", FontWeight.NORMAL, 20));
    grid.add(scenetitle, 0, 0, 1, 1);

    Label userName = new Label("User Name:");
    grid.add(userName, 0, 1);

    TextField userTextField = new TextField("Мудак");
    grid.add(userTextField, 1, 1);

    Label pw = new Label("Password:"******"Sign in");
    HBox hbBtn = new HBox(10);
    hbBtn.setAlignment(Pos.BOTTOM_RIGHT);
    hbBtn.getChildren().add(btn);
    grid.add(hbBtn, 1, 4);

    final Text actiontarget = new Text();
    grid.add(actiontarget, 1, 6);

    btn.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            //                actiontarget.setFill(Color.FIREBRICK);
            actiontarget.setText("Pressed");
          }
        });

    //        grid.setGridLinesVisible(true);

    scenetitle.setId("welc");
    actiontarget.setId("act");

    primaryStage.setScene(sc);
    primaryStage.setTitle("Hello World");
    primaryStage.show();
  }
Esempio n. 2
0
  public void start(Stage stage) {
    Button button = new Button("Click me!");
    button.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            System.out.println("Thanks for clicking!");
          }
        });

    stage.setScene(new Scene(button));
    stage.show();
  }
  /** Initializer */
  protected void init() {
    mFossilUpgradesPane = new FossilUpgradePane(mModel);

    EventHandler<ActionEvent> upgradeEvent = new PanelChangeEvent(mFossilUpgradesPane);
    mFossilUpgrades = new ImageButton("fossilfuelupgrade.png", upgradeEvent);
    mApply = new Button("Apply");

    EventHandler<ActionEvent> applyEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mModel
                .getEnergyManager()
                .getFossil()
                .setAmount(Integer.parseInt(mValues.get("Plants in Operation").getText()));
          }
        };

    EventHandler<ActionEvent> upEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mValues
                .get("Plants in Operation")
                .setText("" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) + 1));
          }
        };

    EventHandler<ActionEvent> downEvent =
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            if (Integer.parseInt(mValues.get("Plants in Operation").getText()) != 0) {
              mValues
                  .get("Plants in Operation")
                  .setText(
                      "" + (Integer.parseInt(mValues.get("Plants in Operation").getText()) - 1));
            }
          }
        };

    mApply.setOnAction(applyEvent);
    mUp = new ImageButton("up.png", upEvent);
    mDown = new ImageButton("down.png", downEvent);
    mUp.setPrefSize(0, 0);
    mDown.setPrefSize(0, 0);
    setHalignment(mDown, HPos.CENTER);
    setHalignment(mUp, HPos.CENTER);
    setHalignment(mApply, HPos.CENTER);
    setHalignment(mFossilUpgrades, HPos.RIGHT);
  }
Esempio n. 4
0
  @Override
  public void start(Stage primaryStage) {
    try {
      TabPane page = (TabPane) FXMLLoader.load(Main.class.getResource("simple.fxml"));
      Scene scene = new Scene(page);
      primaryStage.setScene(scene);
      primaryStage.setTitle("Hotels");
      primaryStage.show();

      textf = (TextField) scene.lookup("#HotelNameTextb");
      Button create = (Button) scene.lookup("#CreateButton");
      create.setOnAction(this::handleButtonAction);

    } catch (Exception ex) {
      Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
    }
  }
Esempio n. 5
0
  protected void init() {
    mActionButton = new Button("Apply");

    mActionButton.setOnAction(
        new EventHandler<ActionEvent>() {
          public void handle(ActionEvent event) {
            mModel.getUpgradeManager().addLobby(mLobby.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mLobby.getChange()));
            mModel.getUpgradeManager().addOilDrilling(mOil.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mOil.getChange()));
            mModel.getUpgradeManager().addPriceChange(mPrice.getChange());
            mModel.getResourceManager().spendActionPoints(Math.abs(mPrice.getChange()));
            mLobby.saveChanges();
            mOil.saveChanges();
            mPrice.saveChanges();
            update();
          }
        });

    setHalignment(mActionButton, HPos.LEFT);
  }