Exemplo 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();
  }
Exemplo 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();
  }
Exemplo n.º 3
0
  /** 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);
  }
Exemplo 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);
    }
  }
 /** Initializes the controller class. */
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   logger.entry();
   OkButton.disableProperty()
       .bind(
           Bindings.isEmpty(FederationExecutionName.textProperty())
               .or(Bindings.isEmpty(FederateType.textProperty())));
   logger.exit();
 }
 @FXML
 private void Ok_click(ActionEvent event) {
   logger.entry();
   LogEntry log = new LogEntry("6.16", "Local Delete Object Instance service");
   try {
     ObjectInstanceHandle instanceHandle =
         rtiAmb
             .getObjectInstanceHandleFactory()
             .decode(
                 ByteBuffer.allocate(4)
                     .putInt(Integer.parseInt(ObjectInstanceDesignator.getText()))
                     .array(),
                 0);
     log.getSuppliedArguments()
         .add(
             new ClassValuePair(
                 "Object instance designator",
                 ObjectInstanceHandle.class,
                 instanceHandle.toString()));
     rtiAmb.localDeleteObjectInstance(instanceHandle);
     log.setDescription("Local Object instance deleted successfully");
     log.setLogType(LogEntryType.REQUEST);
   } catch (FederateNotExecutionMember
       | NotConnected
       | NumberFormatException
       | CouldNotDecode
       | RTIinternalError
       | OwnershipAcquisitionPending
       | FederateOwnsAttributes
       | ObjectInstanceNotKnown
       | SaveInProgress
       | RestoreInProgress ex) {
     log.setException(ex);
     log.setLogType(LogEntryType.ERROR);
     logger.log(Level.ERROR, ex.getMessage(), ex);
   } catch (Exception ex) {
     log.setException(ex);
     log.setLogType(LogEntryType.FATAL);
     logger.log(Level.FATAL, ex.getMessage(), ex);
   }
   logEntries.add(log);
   ((Stage) OkButton.getScene().getWindow()).close();
   logger.exit();
 }
Exemplo n.º 7
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);
  }
 @FXML
 private void Cancel_click(ActionEvent event) {
   logger.entry();
   ((Stage) OkButton.getScene().getWindow()).close();
   logger.exit();
 }
 /** Initializes the controller class. */
 @Override
 public void initialize(URL url, ResourceBundle rb) {
   logger.entry();
   OkButton.disableProperty().bind(ObjectInstanceDesignator.textProperty().isEmpty());
   logger.exit();
 }
Exemplo n.º 10
0
  public static void setJar(final Tile node) {
    node.data.put("type", "Jar");
    List<Node> toRemove = new ArrayList<>();
    for (Node n : node.node.getChildren()) {
      if (!n.getId().equals("delete")) {
        if (n.getId().equals("typeLabel")) {
          Label l = (Label) n;
          l.setText("jar");
          l.setTranslateY(l.getTranslateY() - 1);
        } else {
          toRemove.add(n);
        }
      }
    }

    VBox leftPadding = new VBox();
    leftPadding.setPrefWidth(14);
    VBox buttons = new VBox();
    VBox textBoxes = new VBox();
    VBox extra = new VBox();

    buttons.setSpacing(5);
    textBoxes.setSpacing(5);
    extra.setSpacing(5);

    buttons.setPadding(new Insets(7, 0, 0, 0));
    textBoxes.setPadding(new Insets(7, 0, 0, 0));
    extra.setPadding(new Insets(7, 0, 0, 0));

    textBoxes.setTranslateX(17);
    extra.setTranslateX(32);

    node.node.getChildren().removeAll(toRemove);

    final String name = "Package Name";
    final String name2 = "Jar Name";

    Button findPkg = new Button();
    final TextField pkgText = new TextField();
    final TextField jarName = new TextField();

    findPkg.getStyleClass().add("defaultButton");
    findPkg.setText("Find Package Name");
    findPkg.setPrefHeight(25);
    findPkg.setTranslateX(12);

    findPkg.setOnAction(
        new EventHandler<ActionEvent>() {
          @Override
          public void handle(ActionEvent event) {
            String mainClassName = Util.packageNameFromTile();
            if (mainClassName != null) {
              pkgText.setText(mainClassName);
            }
          }
        });

    pkgText.setText(name);
    pkgText.setPrefSize(150, 27);
    pkgText.setFont(Font.font("Segoe UI"));
    pkgText.setId("textBox");
    pkgText
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("package", pkgText.getText().trim());
              }
            });
    pkgText
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && pkgText.getText().equals(name)) {
                  pkgText.setText("");
                } else if (newValue == false && pkgText.getText().trim().equals("")) {
                  pkgText.setText(name);
                }
              }
            });

    jarName.setText(name2);
    jarName.setPrefSize(150, 27);
    jarName.setFont(Font.font("Segoe UI"));
    jarName.setId("textBox");
    jarName
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("jarname", jarName.getText().trim());
              }
            });
    jarName
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && jarName.getText().equals(name2)) {
                  jarName.setText("");
                } else if (newValue == false && jarName.getText().trim().equals("")) {
                  jarName.setText(name2);
                }
              }
            });

    final String defTxt = "Additional Flags";
    final TextField flags = new TextField();
    flags.setText(defTxt);
    flags.setPrefSize(150, 27);
    flags.setFont(Font.font("Segoe UI"));
    flags.setId("textBox");

    flags
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && flags.getText().equals(defTxt)) {
                  flags.setText("");
                } else if (newValue == false && flags.getText().trim().equals("")) {
                  flags.setText(defTxt);
                }
              }
            });
    flags
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("flags", flags.getText().trim());
              }
            });

    final String defTxt2 = "Output Directory";
    final TextField outputDir = new TextField();
    outputDir.setText(defTxt2);
    outputDir.setPrefSize(150, 27);
    outputDir.setFont(Font.font("Segoe UI"));
    outputDir.setId("textBox");

    outputDir
        .focusedProperty()
        .addListener(
            new ChangeListener<Boolean>() {
              @Override
              public void changed(
                  ObservableValue<? extends Boolean> observable,
                  Boolean oldValue,
                  Boolean newValue) {
                if (newValue == true && outputDir.getText().equals(defTxt2)) {
                  outputDir.setText("");
                } else if (newValue == false && outputDir.getText().trim().equals("")) {
                  outputDir.setText(defTxt2);
                }
              }
            });
    outputDir
        .textProperty()
        .addListener(
            new ChangeListener<String>() {
              @Override
              public void changed(
                  ObservableValue<? extends String> observable, String oldValue, String newValue) {
                node.data.put("output", outputDir.getText().trim());
              }
            });

    buttons.getChildren().addAll(findPkg);
    textBoxes.getChildren().addAll(pkgText, jarName);
    extra.getChildren().addAll(flags, outputDir);
    node.node.getChildren().addAll(leftPadding, buttons, textBoxes, extra);
  }
  /**
   * Here is our whole stage with layout, </Br > ( Grid, TextField and Buttons)
   *
   * @author PatrikWebb
   */
  public void NameDisplay() {
    Stage nameWindow = new Stage();

    // Block events to other windows
    nameWindow.initModality(Modality.APPLICATION_MODAL);
    nameWindow.setTitle("Enter your name");
    nameWindow.setMinWidth(250);

    // GridPane Form
    GridPane grid = new GridPane();
    grid.setPadding(new Insets(10, 10, 10, 10));
    grid.setVgap(8);
    grid.setHgap(10);

    // Name Label
    Label nameLabel = new Label("Player Name:");
    GridPane.setConstraints(nameLabel, 0, 0);

    // Name Input
    nameInput = new TextField();
    nameInput.setPromptText("Name");
    nameInput.setFocusTraversable(false);
    GridPane.setConstraints(nameInput, 1, 0);

    // Betting Label
    Label bettingLabel = new Label("Betting amount: ");
    GridPane.setConstraints(bettingLabel, 0, 1);

    // Bett Input
    playerCashInput = new TextField();
    playerCashInput.setFocusTraversable(false);
    playerCashInput.setPromptText("Betting amount");
    GridPane.setConstraints(playerCashInput, 1, 1);

    // Enter button
    Button enterButton = new Button("Enter");
    enterButton.setFocusTraversable(false);
    // setPercentWidth(50);
    GridPane.setConstraints(enterButton, 1, 2);

    // Cancel button
    Button cancelButton = new Button("Demo Player");
    cancelButton.setFocusTraversable(false);
    GridPane.setConstraints(cancelButton, 2, 2);

    //
    enterButton.setOnAction(
        e -> {
          Platform.runLater(
              () -> {
                // Get the input from the nameInput TextField
                name = nameInput.getText();
                // Get the betting input from the bettsInput TextField
                playerCash = Integer.parseInt(playerCashInput.getText());
                // Add name and playerCash input to a new player
                Bank.getInstance().addPlayerToBank(name, playerCash);
                // Add the player to the table
                Bank.getInstance().addPlayersToTheTable();
                // Close the stage
                nameWindow.close();

                System.out.println("\nPlayer Name: " + name);
                System.out.println("Betting Amount: " + playerCash + "\n");
              });
        });

    cancelButton.setOnAction(
        e -> {
          // TODO
          Platform.runLater(
              () -> {

                /* * * * * * * * * * * * *
                 * If you press cancel you still want a player to join
                 * the table so I add a test player insted of
                 * getting the error, Exception JavaFX Application THREAD ;)
                 *  * * * * * * * * * * * */
                Bank.getInstance().addPlayerToBank("Demo Player", 500);
                // Add the player to the table
                Bank.getInstance().addPlayersToTheTable();
                nameWindow.close();
              });
        });

    // Add everything to grid
    grid.getChildren()
        .addAll(nameLabel, nameInput, bettingLabel, playerCashInput, enterButton, cancelButton);

    // Display window and wait for it to be closed before returning
    Scene scene = new Scene(grid, 450, 150);
    nameWindow.setScene(scene);
    nameWindow.showAndWait();
  }