Пример #1
0
 public static void removeRowsFromGridPane(GridPane gridPane, int fromGridRow, int toGridRow) {
   Set<Node> nodes = new CopyOnWriteArraySet<>(gridPane.getChildren());
   nodes
       .stream()
       .filter(e -> GridPane.getRowIndex(e) >= fromGridRow && GridPane.getRowIndex(e) <= toGridRow)
       .forEach(e -> gridPane.getChildren().remove(e));
 }
Пример #2
0
 public static Label addLabel(GridPane gridPane, int rowIndex, String title, double top) {
   Label label = new Label(title);
   GridPane.setRowIndex(label, rowIndex);
   GridPane.setMargin(label, new Insets(top, 0, 0, 0));
   gridPane.getChildren().add(label);
   return label;
 }
Пример #3
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();
  }
Пример #4
0
 public static RadioButton addRadioButton(GridPane gridPane, int rowIndex, String title) {
   RadioButton radioButton = new RadioButton(title);
   GridPane.setRowIndex(radioButton, rowIndex);
   GridPane.setColumnIndex(radioButton, 1);
   gridPane.getChildren().add(radioButton);
   return radioButton;
 }
Пример #5
0
 public static Button addButton(GridPane gridPane, int rowIndex, String title) {
   Button button = new Button(title);
   button.setDefaultButton(true);
   GridPane.setRowIndex(button, rowIndex);
   GridPane.setColumnIndex(button, 1);
   gridPane.getChildren().add(button);
   return button;
 }
Пример #6
0
 public static CheckBox addCheckBox(
     GridPane gridPane, int rowIndex, String checkBoxTitle, double top) {
   CheckBox checkBox = new CheckBox(checkBoxTitle);
   GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
   GridPane.setRowIndex(checkBox, rowIndex);
   GridPane.setColumnIndex(checkBox, 1);
   gridPane.getChildren().add(checkBox);
   return checkBox;
 }
Пример #7
0
 public static Button addButtonAfterGroup(GridPane gridPane, int rowIndex, String title) {
   Button button = new Button(title);
   button.setDefaultButton(true);
   GridPane.setRowIndex(button, rowIndex);
   GridPane.setColumnIndex(button, 1);
   GridPane.setMargin(button, new Insets(15, 0, 0, 0));
   gridPane.getChildren().add(button);
   return button;
 }
Пример #8
0
 public static Label addMultilineLabel(GridPane gridPane, int rowIndex, String text, double top) {
   Label label = new Label(text);
   label.setWrapText(true);
   GridPane.setHalignment(label, HPos.LEFT);
   GridPane.setRowIndex(label, rowIndex);
   GridPane.setColumnSpan(label, 2);
   GridPane.setMargin(label, new Insets(top, 0, 0, 0));
   gridPane.getChildren().add(label);
   return label;
 }
Пример #9
0
  public static Tuple2<Label, BalanceTextField> addLabelBalanceTextField(
      GridPane gridPane, int rowIndex, String title) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    BalanceTextField balanceTextField = new BalanceTextField();
    GridPane.setRowIndex(balanceTextField, rowIndex);
    GridPane.setColumnIndex(balanceTextField, 1);
    gridPane.getChildren().add(balanceTextField);

    return new Tuple2<>(label, balanceTextField);
  }
Пример #10
0
  public static Tuple2<Label, DatePicker> addLabelDatePicker(
      GridPane gridPane, int rowIndex, String title) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    DatePicker datePicker = new DatePicker();
    GridPane.setRowIndex(datePicker, rowIndex);
    GridPane.setColumnIndex(datePicker, 1);
    gridPane.getChildren().add(datePicker);

    return new Tuple2<>(label, datePicker);
  }
Пример #11
0
  public static Tuple2<Label, AddressTextField> addLabelAddressTextField(
      GridPane gridPane, int rowIndex, String title) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    AddressTextField addressTextField = new AddressTextField();
    GridPane.setRowIndex(addressTextField, rowIndex);
    GridPane.setColumnIndex(addressTextField, 1);
    gridPane.getChildren().add(addressTextField);

    return new Tuple2<>(label, addressTextField);
  }
 /**
  * Gets the Node at a given location in the GridPane
  *
  * @param row the row (y-coordinate) where to get the Node
  * @param column the column (x-coordinate) where to get the Node
  * @param gridPane the GridPane to get a Node from
  * @return the Node at that given location from the GridPane
  */
 private Node getNodeFromIndex(int row, int column, GridPane gridPane) {
   Node result = null;
   ObservableList<Node> childrens = gridPane.getChildren();
   for (Node node : childrens) {
     if (gridPane.getRowIndex(node) == row && gridPane.getColumnIndex(node) == column) {
       result = node;
       break;
     }
   }
   return result;
 }
Пример #13
0
 public static TitledGroupBg addTitledGroupBg(
     GridPane gridPane, int rowIndex, int rowSpan, String title, double top) {
   TitledGroupBg titledGroupBg = new TitledGroupBg();
   titledGroupBg.setText(title);
   titledGroupBg.prefWidthProperty().bind(gridPane.widthProperty());
   GridPane.setRowIndex(titledGroupBg, rowIndex);
   GridPane.setRowSpan(titledGroupBg, rowSpan);
   GridPane.setColumnSpan(titledGroupBg, 2);
   GridPane.setMargin(titledGroupBg, new Insets(top, -10, -10, -10));
   gridPane.getChildren().add(titledGroupBg);
   return titledGroupBg;
 }
Пример #14
0
  public static Tuple2<Label, TxIdTextField> addLabelTxIdTextField(
      GridPane gridPane, int rowIndex, String title, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    TxIdTextField txIdTextField = new TxIdTextField();
    GridPane.setRowIndex(txIdTextField, rowIndex);
    GridPane.setColumnIndex(txIdTextField, 1);
    GridPane.setMargin(txIdTextField, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(txIdTextField);

    return new Tuple2<>(label, txIdTextField);
  }
Пример #15
0
  public static Tuple2<Label, ListView> addLabelListView(
      GridPane gridPane, int rowIndex, String title, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    ListView listView = new ListView();
    GridPane.setRowIndex(listView, rowIndex);
    GridPane.setColumnIndex(listView, 1);
    GridPane.setMargin(listView, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(listView);

    return new Tuple2<>(label, listView);
  }
Пример #16
0
  public static Tuple2<Label, CheckBox> addLabelCheckBox(
      GridPane gridPane, int rowIndex, String title, String checkBoxTitle, double top) {
    Label label = addLabel(gridPane, rowIndex, title, -3);
    GridPane.setMargin(label, new Insets(top, 0, 0, 0));

    CheckBox checkBox = new CheckBox(checkBoxTitle);
    GridPane.setRowIndex(checkBox, rowIndex);
    GridPane.setColumnIndex(checkBox, 1);
    GridPane.setMargin(checkBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(checkBox);

    return new Tuple2<>(label, checkBox);
  }
Пример #17
0
  public static Tuple2<Label, ComboBox> addLabelComboBox(
      GridPane gridPane, int rowIndex, String title, double top) {
    Label label = null;
    if (title != null) label = addLabel(gridPane, rowIndex, title, top);

    ComboBox comboBox = new ComboBox();
    GridPane.setRowIndex(comboBox, rowIndex);
    GridPane.setColumnIndex(comboBox, 1);
    GridPane.setMargin(comboBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(comboBox);

    return new Tuple2<>(label, comboBox);
  }
Пример #18
0
  public static Tuple2<Label, TextFieldWithCopyIcon> addLabelTextFieldWithCopyIcon(
      GridPane gridPane, int rowIndex, String title, String value, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    TextFieldWithCopyIcon textFieldWithCopyIcon = new TextFieldWithCopyIcon();
    textFieldWithCopyIcon.setText(value);
    GridPane.setRowIndex(textFieldWithCopyIcon, rowIndex);
    GridPane.setColumnIndex(textFieldWithCopyIcon, 1);
    GridPane.setMargin(textFieldWithCopyIcon, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textFieldWithCopyIcon);

    return new Tuple2<>(label, textFieldWithCopyIcon);
  }
  public void createWallLine(int y) {
    PositionButton button;
    Pane wallRec;

    for (int x = 0; x < 8; x++) {
      wallRec = new Pane();
      wallRec.setPrefSize(30, 10);
      wallRec.setId("wallRec");

      horizontalWalls[x][y] = wallRec;
      gameGrid.setConstraints(horizontalWalls[x][y], column, row);
      gameGrid.getChildren().add(horizontalWalls[x][y]);

      column++;

      button = new WallPositionButton(new Position(x, y));
      button.setPrefSize(10, 10);
      button.setId("wallPosBtn");

      wallPositionButtons[x][y] = button;

      gameGrid.setConstraints(wallPositionButtons[x][y], column, row);
      gameGrid.getChildren().addAll(wallPositionButtons[x][y]);

      column++;
    }

    wallRec = new Pane();
    wallRec.setPrefSize(30, 10);
    wallRec.setId("wallRec");

    horizontalWalls[8][y] = wallRec;
    gameGrid.setConstraints(horizontalWalls[8][y], column, row);
    gameGrid.getChildren().add(horizontalWalls[8][y]);

    column = 0;
    row++;
  }
Пример #20
0
 public static Tuple2<Button, Button> add2ButtonsAfterGroup(
     GridPane gridPane, int rowIndex, String title1, String title2, double top) {
   HBox hBox = new HBox();
   hBox.setSpacing(10);
   Button button1 = new Button(title1);
   button1.setDefaultButton(true);
   Button button2 = new Button(title2);
   hBox.getChildren().addAll(button1, button2);
   GridPane.setRowIndex(hBox, rowIndex);
   GridPane.setColumnIndex(hBox, 1);
   GridPane.setMargin(hBox, new Insets(top, 10, 0, 0));
   gridPane.getChildren().add(hBox);
   return new Tuple2<>(button1, button2);
 }
  public void createMoveLine(int y) {
    PositionButton button;
    Pane wallRec;

    button = new PlayerPositionButton(new Position(0, y));
    button.setPrefSize(60, 60);
    button.setId("board");

    playerPositionButtons[0][y] = button;
    gameGrid.setConstraints(button, column, row);
    gameGrid.getChildren().addAll(playerPositionButtons[0][y]);

    for (int x = 1; x < 9; x++) {
      column++;

      wallRec = new Pane();
      wallRec.setPrefSize(10, 30);
      wallRec.setId("wallRec");

      verticalWalls[x][y] = wallRec;
      gameGrid.setConstraints(wallRec, column, row);
      gameGrid.getChildren().add(verticalWalls[x][y]);

      column++;

      button = new PlayerPositionButton(new Position(x, y));
      button.setPrefSize(60, 60);

      button.setId("board");

      playerPositionButtons[x][y] = button;
      gameGrid.setConstraints(button, column, row);
      gameGrid.getChildren().addAll(playerPositionButtons[x][y]);
    }
    column = 0;
    row++;
  }
Пример #22
0
  public static Tuple2<Label, TextField> addLabelTextField(
      GridPane gridPane, int rowIndex, String title, String value, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    TextField textField = new TextField(value);
    textField.setEditable(false);
    textField.setMouseTransparent(true);
    textField.setFocusTraversable(false);
    GridPane.setRowIndex(textField, rowIndex);
    GridPane.setColumnIndex(textField, 1);
    GridPane.setMargin(textField, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textField);

    return new Tuple2<>(label, textField);
  }
Пример #23
0
  public static Tuple2<Label, TextArea> addLabelTextArea(
      GridPane gridPane, int rowIndex, String title, String prompt, double top) {
    Label label = addLabel(gridPane, rowIndex, title, 0);
    GridPane.setMargin(label, new Insets(top + 4, 0, 0, 0));
    GridPane.setValignment(label, VPos.TOP);

    TextArea textArea = new TextArea();
    textArea.setPromptText(prompt);
    textArea.setWrapText(true);
    GridPane.setRowIndex(textArea, rowIndex);
    GridPane.setColumnIndex(textArea, 1);
    GridPane.setMargin(textArea, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(textArea);

    return new Tuple2<>(label, textArea);
  }
Пример #24
0
  public static Tuple3<Label, InputTextField, CheckBox> addLabelInputTextFieldCheckBox(
      GridPane gridPane, int rowIndex, String title, String checkBoxTitle) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    InputTextField inputTextField = new InputTextField();
    CheckBox checkBox = new CheckBox(checkBoxTitle);
    checkBox.setPadding(new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(10);
    hBox.getChildren().addAll(inputTextField, checkBox);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    gridPane.getChildren().add(hBox);

    return new Tuple3<>(label, inputTextField, checkBox);
  }
Пример #25
0
  public static Tuple2<Button, CheckBox> addButtonCheckBox(
      GridPane gridPane, int rowIndex, String buttonTitle, String checkBoxTitle, double top) {
    Button button = new Button(buttonTitle);
    button.setDefaultButton(true);
    CheckBox checkBox = new CheckBox(checkBoxTitle);
    HBox.setMargin(checkBox, new Insets(6, 0, 0, 0));

    HBox hBox = new HBox();
    hBox.setSpacing(20);
    hBox.getChildren().addAll(button, checkBox);
    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    hBox.setPadding(new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple2<>(button, checkBox);
  }
Пример #26
0
  public static Tuple2<Label, RadioButton> addLabelRadioButton(
      GridPane gridPane,
      int rowIndex,
      ToggleGroup toggleGroup,
      String title,
      String radioButtonTitle) {
    Label label = addLabel(gridPane, rowIndex, title, 0);

    RadioButton radioButton = new RadioButton(radioButtonTitle);
    radioButton.setToggleGroup(toggleGroup);
    radioButton.setPadding(new Insets(6, 0, 0, 0));
    GridPane.setRowIndex(radioButton, rowIndex);
    GridPane.setColumnIndex(radioButton, 1);
    gridPane.getChildren().add(radioButton);

    return new Tuple2<>(label, radioButton);
  }
Пример #27
0
  public static Tuple3<Label, ComboBox, ComboBox> addLabelComboBoxComboBox(
      GridPane gridPane, int rowIndex, String title, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    HBox hBox = new HBox();
    hBox.setSpacing(10);

    ComboBox comboBox1 = new ComboBox();
    ComboBox comboBox2 = new ComboBox();
    hBox.getChildren().addAll(comboBox1, comboBox2);

    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    // GridPane.setMargin(hBox, new Insets(15, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple3<>(label, comboBox1, comboBox2);
  }
Пример #28
0
  public static Tuple3<Label, ComboBox, Button> addLabelComboBoxButton(
      GridPane gridPane, int rowIndex, String title, String buttonTitle, double top) {
    Label label = addLabel(gridPane, rowIndex, title, top);

    HBox hBox = new HBox();
    hBox.setSpacing(10);

    Button button = new Button(buttonTitle);
    button.setDefaultButton(true);

    ComboBox comboBox = new ComboBox();

    hBox.getChildren().addAll(comboBox, button);

    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(15, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple3<>(label, comboBox, button);
  }
Пример #29
0
  public static Tuple3<Button, ProgressIndicator, Label> addButtonWithStatus(
      GridPane gridPane, int rowIndex, String buttonTitle, double top) {
    HBox hBox = new HBox();
    hBox.setSpacing(10);
    Button button = new Button(buttonTitle);
    button.setDefaultButton(true);

    ProgressIndicator progressIndicator = new ProgressIndicator(0);
    progressIndicator.setPrefHeight(24);
    progressIndicator.setPrefWidth(24);
    progressIndicator.setVisible(false);

    Label label = new Label();
    label.setPadding(new Insets(5, 0, 0, 0));

    hBox.getChildren().addAll(button, progressIndicator, label);

    GridPane.setRowIndex(hBox, rowIndex);
    GridPane.setColumnIndex(hBox, 1);
    GridPane.setMargin(hBox, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(hBox);

    return new Tuple3<>(button, progressIndicator, label);
  }
  public GridPaneSample() {

    VBox vbox = new VBox();

    // grid1 places the child by specifying the rows and columns in
    // GridPane.setContraints()
    Label grid1Caption =
        new Label(
            "The example below shows GridPane content placement by specifying rows and columns:");
    grid1Caption.setWrapText(true);
    GridPane grid1 = new GridPane();
    grid1.setHgap(4);
    grid1.setVgap(6);
    grid1.setPadding(new Insets(18, 18, 18, 18));
    ObservableList<Node> content = grid1.getChildren();

    Label label = new Label("Name:");
    GridPane.setConstraints(label, 0, 0);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("John Q. Public");
    GridPane.setConstraints(label, 1, 0, 2, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    label = new Label("Address:");
    GridPane.setConstraints(label, 0, 1);
    GridPane.setHalignment(label, HPos.RIGHT);
    content.add(label);

    label = new Label("12345 Main Street, Some City, CA");
    GridPane.setConstraints(label, 1, 1, 5, 1);
    GridPane.setHalignment(label, HPos.LEFT);
    content.add(label);

    vbox.getChildren().addAll(grid1Caption, grid1, new Separator());

    // grid2 places the child by influencing the rows and columns themselves
    // via GridRowInfo and GridColumnInfo. This grid uses the preferred
    // width/height and max/min width/height.
    Label grid2Caption =
        new Label(
            "The example below shows GridPane content placement by influencing the rows and columns themselves.");
    grid2Caption.setWrapText(true);
    grid2Caption.setWrapText(true);
    GridPane grid2 = new GridPane();
    grid2.setPadding(new Insets(18, 18, 18, 18));
    RowConstraints rowinfo = new RowConstraints(40, 40, 40);
    ColumnConstraints colinfo = new ColumnConstraints(90, 90, 90);

    for (int i = 0; i <= 2; i++) {
      grid2.getRowConstraints().add(rowinfo);
    }

    for (int j = 0; j <= 2; j++) {
      grid2.getColumnConstraints().add(colinfo);
    }

    Label category = new Label("Category:");
    GridPane.setHalignment(category, HPos.RIGHT);
    Label categoryValue = new Label("Wines");
    Label company = new Label("Company:");
    GridPane.setHalignment(company, HPos.RIGHT);
    Label companyValue = new Label("Acme Winery");
    Label rating = new Label("Rating:");
    GridPane.setHalignment(rating, HPos.RIGHT);
    Label ratingValue = new Label("Excellent");

    ImageView imageView = new ImageView(ICON_48);
    GridPane.setHalignment(imageView, HPos.CENTER);

    // Place content
    GridPane.setConstraints(category, 0, 0);
    GridPane.setConstraints(categoryValue, 1, 0);
    GridPane.setConstraints(company, 0, 1);
    GridPane.setConstraints(companyValue, 1, 1);
    GridPane.setConstraints(imageView, 2, 1);
    GridPane.setConstraints(rating, 0, 2);
    GridPane.setConstraints(ratingValue, 1, 2);
    grid2
        .getChildren()
        .addAll(category, categoryValue, company, companyValue, imageView, rating, ratingValue);

    vbox.getChildren().addAll(grid2Caption, grid2, new Separator());

    // grid3 places the child by influencing the rows and columns
    // via GridRowInfo and GridColumnInfo. This grid uses the percentages
    Label grid3Caption =
        new Label(
            "The example below shows GridPane content placement by influencing row and column percentages.  Also, grid lines are made visible in this example.  The lines can be helpful in debugging.");
    grid3Caption.setWrapText(true);
    GridPane grid3 = new GridPane();
    grid3.setPadding(new Insets(18, 18, 18, 18));
    grid3.setGridLinesVisible(true);
    RowConstraints rowinfo3 = new RowConstraints();
    rowinfo3.setPercentHeight(50);

    ColumnConstraints colInfo2 = new ColumnConstraints();
    colInfo2.setPercentWidth(25);

    ColumnConstraints colInfo3 = new ColumnConstraints();
    colInfo3.setPercentWidth(50);

    grid3.getRowConstraints().add(rowinfo3); // 2*50 percent
    grid3.getRowConstraints().add(rowinfo3);

    grid3.getColumnConstraints().add(colInfo2); // 25 percent
    grid3.getColumnConstraints().add(colInfo3); // 50 percent
    grid3.getColumnConstraints().add(colInfo2); // 25 percent

    Label condLabel = new Label(" Member Name:");
    GridPane.setHalignment(condLabel, HPos.RIGHT);
    GridPane.setConstraints(condLabel, 0, 0);
    Label condValue = new Label("MyName");
    GridPane.setMargin(condValue, new Insets(0, 0, 0, 10));
    GridPane.setConstraints(condValue, 1, 0);

    Label acctLabel = new Label("Member Number:");
    GridPane.setHalignment(acctLabel, HPos.RIGHT);
    GridPane.setConstraints(acctLabel, 0, 1);
    TextField textBox = new TextField("Your number");
    GridPane.setMargin(textBox, new Insets(10, 10, 10, 10));
    GridPane.setConstraints(textBox, 1, 1);

    Button button = new Button("Help");
    GridPane.setConstraints(button, 2, 1);
    GridPane.setMargin(button, new Insets(10, 10, 10, 10));
    GridPane.setHalignment(button, HPos.CENTER);

    GridPane.setConstraints(condValue, 1, 0);
    grid3.getChildren().addAll(condLabel, condValue, button, acctLabel, textBox);

    vbox.getChildren().addAll(grid3Caption, grid3);

    getChildren().add(vbox);
  }