Exemplo n.º 1
0
  public void open() throws IOException {

    paneCenter.getChildren().clear();

    String station = (String) cbStations.getValue();

    File f = new File("database\\" + station + "\\status.txt");
    FileReader fr1 = new FileReader(f);
    LineNumberReader ln = new LineNumberReader(fr1);
    int count = 0;
    while (ln.readLine() != null) {
      count++;
    }
    ln.close();
    fr1.close();

    FileReader fr2 = new FileReader(f);
    BufferedReader br = new BufferedReader(fr2);

    paneCenter.add(new Label("Last seen : " + (br.readLine())), 0, 0);

    for (int i = 1; i < count; i++) {
      paneCenter.add(new Label(br.readLine()), 0, i);
    }
    br.close();
    fr2.close();

    addQuantityToCB();
  }
Exemplo n.º 2
0
  public void displayPane() throws IOException {

    addStationsToCB();

    paneTop.getColumnConstraints().add(new ColumnConstraints(60));
    paneTop.getColumnConstraints().add(new ColumnConstraints(200));
    paneTop.getColumnConstraints().add(new ColumnConstraints(100));

    paneBot.getColumnConstraints().add(new ColumnConstraints(60));
    paneBot.getColumnConstraints().add(new ColumnConstraints(200));
    paneBot.getColumnConstraints().add(new ColumnConstraints(100));

    paneCenter.getColumnConstraints().add(new ColumnConstraints(300));

    paneTop.setPadding(new Insets(10, 10, 10, 10));
    paneTop.setAlignment(Pos.CENTER);
    paneTop.setHgap(5);
    paneTop.setVgap(5);

    paneBot.setPadding(new Insets(10, 10, 10, 10));
    paneBot.setAlignment(Pos.CENTER);
    paneBot.setHgap(5);
    paneBot.setVgap(5);

    paneTop.add(new Label("Station :"), 0, 0);
    paneTop.add(cbStations, 1, 0);
    paneTop.add(btOpen, 2, 0);

    paneBot.add(new Label("Quantity :"), 0, 0);
    paneBot.add(cbQuantity, 1, 0);
    paneBot.add(btShow, 2, 0);

    paneTop.setHalignment(btOpen, HPos.RIGHT);
    paneBot.setHalignment(btShow, HPos.RIGHT);

    paneCenter.setHgap(5);
    paneCenter.setVgap(5);
    paneCenter.setAlignment(Pos.CENTER);
    sp.setContent(paneCenter);
    sp.setVbarPolicy(ScrollPane.ScrollBarPolicy.ALWAYS);
    bp.setMargin(sp, new Insets(20, 50, 40, 50));
    bp.setTop(paneTop);
    bp.setCenter(sp);
    bp.setBottom(paneBot);

    btOpen.setOnAction(
        e -> {
          try {
            open();
          } catch (IOException er) {
            er.printStackTrace();
          }
        });

    btShow.setOnAction(e -> showGraph());
  }
Exemplo n.º 3
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();
  }
  /**
   * 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();
  }