Package javafx.scene.layout

Examples of javafx.scene.layout.HBox


    month = today.get(Calendar.MONTH);
    year = today.get(Calendar.YEAR);
    dateProperty = new SimpleObjectProperty<Date>((new GregorianCalendar()).getTime());
   
    // First block of the picker pane, which is constructed to show month and year and to change them by decreasing and increasing.
    HBox monthYearRow = new HBox();
    final Label monthYear = new Label(getMonthYear((new GregorianCalendar()).getTime()));
    monthYear.setMinHeight(CELL_HEIGHT * 1.5);
    monthYear.setMinWidth(CELL_WIDTH * 6.0);
    monthYear.setAlignment(Pos.CENTER);
    monthYearRow.getStyleClass().add(DATEPICKER_MONTHYEAR);
    Path decrementArrow = new Path();
    decrementArrow.setId(DATEPICKER_ARROW);
    decrementArrow.getElements().addAll(new MoveTo(0, ARROW_SIZE), new LineTo(0, -ARROW_SIZE),
        new LineTo(-ARROW_SIZE, 0), new LineTo(0, ARROW_SIZE));
    decrementArrow.setOnMouseClicked(new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent me) {
        month--;
        if(month < 0) {
          month = Calendar.DECEMBER;
          year--;
        }
        monthYear.setText(getMonthYear((new GregorianCalendar(year, month, 1)).getTime()));
        setDayCells();
        me.consume();
      }
    });
    Path inreamentArrow = new Path();
    inreamentArrow.setId(DATEPICKER_ARROW);
    inreamentArrow.getElements().addAll(new MoveTo(0, ARROW_SIZE), new LineTo(0, -ARROW_SIZE),
        new LineTo(ARROW_SIZE, 0), new LineTo(0, ARROW_SIZE));
    inreamentArrow.setOnMouseClicked(new EventHandler<MouseEvent>() {
      @Override
      public void handle(MouseEvent me) {
        month++;
        if(month > Calendar.DECEMBER) {
          month = Calendar.JANUARY;
          year++;
        }
        monthYear.setText(getMonthYear((new GregorianCalendar(year, month, 1)).getTime()));
        setDayCells();
        me.consume();
      }
    });
    monthYearRow.getChildren().addAll(decrementArrow, monthYear, inreamentArrow);
    monthYearRow.setAlignment(Pos.CENTER);
   
    // Second block of the picker pane, which is constructed to show the first letter of names of days in the week.   
    HBox firstLetterOfDayRow = new HBox();
    firstLetterOfDayRow.getStyleClass().add(DATEPICKER_WEEKDAY);
    String[] weekDays = getFirstLettersOfDays();
    for (int i = 0; i < weekDays.length; i++) {
      Label cell = new Label(weekDays[i]);
      cell.setMinHeight(CELL_HEIGHT);
      cell.setMinWidth(CELL_WIDTH);
      cell.setAlignment(Pos.CENTER);
      firstLetterOfDayRow.getChildren().add(cell);
    }
    pickerBox.getChildren().addAll(monthYearRow, firstLetterOfDayRow);
   
    // Third block of the picker pane, which is constructed to show the days in a ROW_NUMBER by COLUMN_NUMBER matrix.
    // The matrix constitutes of DayCell class which extends Label class and holds date information.
    dayCells = new DayCell[COLUMN_NUMBER * ROW_NUMBER];
    int index = 0;
    for (int i = 0; i < ROW_NUMBER; i++) {
      HBox row = new HBox();
      for (int j = 0; j < COLUMN_NUMBER; j++) {
        DayCell cell = createCell(0, 0, 0);
        row.getChildren().add(cell);
        cell.setId(DATEPICKER_DAYCELL);
        dayCells[index++] = cell;
      }
      pickerBox.getChildren().add(row);
    }
   
    Button todayButton = new Button(RS.rbLabel(KEY.TODAY));
    todayButton.setId(DATEPICKER_TODAYBUTTON);
    todayButton.setOnAction(new EventHandler<ActionEvent>() {
     
      @Override
      public void handle(ActionEvent ae) {
        dateProperty.setValue((new GregorianCalendar(0, 0, 0)).getTime());
        dateProperty.setValue(
            (new GregorianCalendar(
                today.get(Calendar.YEAR),
                today.get(Calendar.MONTH),
                today.get(Calendar.DAY_OF_MONTH))).getTime());
       
      }
    });
   
    HBox todayButtonBox = new HBox();
    todayButtonBox.setId(DATEPICKER_TODAYBUTTONBOX);
    todayButtonBox.setAlignment(Pos.CENTER);
    todayButtonBox.getChildren().add(todayButton);
   
    pickerBox.getChildren().add(todayButtonBox);
   
    getChildren().add(pickerBox);
   
View Full Code Here


  /**
   * Draws the toggle switch
   */
    protected void draw() {
      // skin approach uses more resources to manage
      final HBox textView = new HBox(TEXT_SPACING);
      textView.setCache(true);
      textView.setCacheHint(CacheHint.SPEED);
      textView.widthProperty().addListener(new ChangeListener<Number>() {
      @Override
      public void changed(ObservableValue<? extends Number> observable,
          Number oldValue, Number newValue) {
        final Bounds textViewBounds = textView.getBoundsInLocal();
        mainRec.setX(textViewBounds.getMinX());
        mainRec.setWidth(textViewBounds.getWidth());
        middleRec.setWidth(mainRec.getWidth() / 2);
      }
    });
      textView.heightProperty().addListener(new ChangeListener<Number>() {
      @Override
      public void changed(ObservableValue<? extends Number> observable,
          Number oldValue, Number newValue) {
        final Bounds textViewBounds = textView.getBoundsInLocal();
        mainRec.setY(textViewBounds.getMinY());
        mainRec.setHeight(textViewBounds.getHeight());
        middleRec.setHeight(mainRec.getHeight());
      }
    });
     
        final Label onLabel = new Label();
        onLabel.setCache(true);
        onLabel.setCacheHint(CacheHint.SPEED);
        onLabel.setText(onText);
        onLabel.setTextFill(Color.WHITE);
        onLabel.setStyle("-fx-text-fill: #FFFFFF; -fx-font-size: 12pt; -fx-font-weight: bold;");
        final Label offLabel = new Label();
        offLabel.setCache(true);
        offLabel.setText(offText);
        offLabel.setStyle("-fx-text-fill: #333333; -fx-font-size: 12pt; -fx-font-weight: bold;");
        HBox.setMargin(onLabel, TEXT_INSETS);
        HBox.setMargin(offLabel, TEXT_INSETS);
    textView.getChildren().addAll(onLabel, offLabel);
   
      mainRec = new Rectangle();
      mainRec.setSmooth(false);
      mainRec.setCache(true);
      mainRec.setCacheHint(CacheHint.SPEED);
View Full Code Here

        RemoteNodeType.UNIVERSAL_REMOTE_ACCESS_CODE_3,
        ACCESS_KEY_CODE_FORMAT, null, null, null, RS.rbLabel(
            KEY.WIRELESS_ACCESS_KEY, 3), null);
      controlBar.addHelpTextTrigger(accessKey3, RS.rbLabel(KEY.WIRELESS_ACCESS_KEY_DESC, 3));
     
      final HBox accessKeysContainer = new HBox(5);
      accessKeysContainer.getChildren().addAll(accessKey1, accessKey2, accessKey3);
     
    final Parent setupCell = createCell(nodeLabel, remoteAddress, workingDir, alarmMultistates,
        univRemoteLabel, universalRemoteAccessToggleSwitch, accessKeysContainer);
    add(setupCell, columnIndex, rowIndex);
  }
View Full Code Here

      controlBar.addHelpTextTrigger(webHostLocal, RS.rbLabel(KEY.WEB_HOST_LOCAL_DESC));
      webPortLocal = new UGateCtrlBox<>(cb.getActorPA(), ActorType.WEB_PORT_LOCAL,
        UGateCtrlBox.Type.TEXT, RS.rbLabel(KEY.WEB_PORT_LOCAL), null);
      controlBar.addHelpTextTrigger(webPortLocal, RS.rbLabel(KEY.WEB_PORT_LOCAL_DESC));
   
    final HBox wirelessBtnView = new HBox();
    wirelessOnAtStartSwitch = new UGateToggleSwitchBox<>(
        controlBar.getActorPA(), ActorType.COM_ON_AT_APP_STARTUP, null,
        null, RS.rbLabel(KEY.APP_SERVICE_STARTUP_AUTO),
        RS.rbLabel(KEY.APP_SERVICE_STARTUP_MANUAL));
    controlBar.addHelpTextTrigger(wirelessOnAtStartSwitch, RS.rbLabel(KEY.APP_SERVICE_STARTUP_DESC));
    wirelessBtn = new Button(RS.rbLabel(KEY.WIRELESS_CONNECT));
    controlBar.addHelpTextTrigger(wirelessBtn, RS.rbLabel(KEY.WIRELESS_WEB_START_STOP_DESC));
    cb.addServiceBehavior(wirelessBtn, null, ServiceProvider.Type.WIRELESS,
        KEY.WIRELESS_CONNECT_DESC);
    wirelessBtnView.getChildren().addAll(wirelessBtn, wirelessOnAtStartSwitch);
   
    final HBox webBtnView = new HBox();
    webOnAtStartSwitch = new UGateToggleSwitchBox<>(
        controlBar.getActorPA(), ActorType.WEB_ON_AT_COM_STARTUP, null,
        null, RS.rbLabel(KEY.APP_SERVICE_STARTUP_AUTO),
        RS.rbLabel(KEY.APP_SERVICE_STARTUP_MANUAL));
    controlBar.addHelpTextTrigger(webOnAtStartSwitch, RS.rbLabel(KEY.APP_SERVICE_HOST_STARTUP_DESC));
    webBtn = new Button(RS.rbLabel(KEY.WIRELESS_WEB_START_STOP));
    cb.addServiceBehavior(webBtn, null, ServiceProvider.Type.WEB,
        KEY.WIRELESS_WEB_START_STOP_DESC);
    webBtnView.getChildren().addAll(webBtn, webOnAtStartSwitch);

    getChildren().addAll(
        createIconGrid(wirelessIcon, port, baud, hostAddress),
        wirelessBtnView,
        createIconGrid(webIcon, webHost, webPort, webHostLocal,
View Full Code Here

    beanPane.setPadding(new Insets(10, 10, 10, 10));
    final Text title = new Text(
        "Person POJO using auto-generated JavaFX properties. "
            + "Duplicate field controls exist to demo multiple control binding");
    title.setWrappingWidth(400d);
    HBox hobbyBox = beanTF("allHobbies", "hobbies", "name", Hobby.class, 0,
        ListView.class, null, HOBBY_OVERWRITE);
    HBox langBox = beanTF("allLanguages", "languages", null, String.class,
        0, ListView.class, null, shouldNeverAppear);
    final HBox stBox = beanTF("address.location.state", null, null, null,
        2, ComboBox.class, "[a-zA-z]", STATES);
    personBox.getChildren().addAll(
        beanTF("name", null, null, null, 50, null, "[a-zA-z0-9\\s]*"),
        beanTF("age", null, null, null, 100, Slider.class, null),
        beanTF("age", null, null, null, 100, null, "[0-9]"),
View Full Code Here

    beanBox.getChildren().addAll(toolBar, pojoSplit);
    return beanBox;
  }

  public HBox createRoleField(String rolePath) {
    HBox cont = new HBox();
    final Role r1 = new Role();
    final Role r2 = new Role();
    r1.setName("User");
    r1.setDescription("General user role");
    r2.setName("Admin");
    r2.setDescription("Administrator role");
    ComboBox<Role> cb = new ComboBox<>();
    cb.setPromptText("Select Role");
    cb.getItems().addAll(r1, r2);
    cb.setValue(r1);
    personPA.bindBidirectional(rolePath, cb.valueProperty(), Role.class);
    cont.getChildren().addAll(new Label(rolePath + " = "), cb);
    return cont;
  }
View Full Code Here

        for (Object sel : sels) {
          listView.getItems().remove(sel);
        }
      }
    });
    HBox btnBox = new HBox();
    btnBox.getChildren().addAll(addBtn, remBtn, remSelBtn);
    VBox box = new VBox();
    box.getChildren().addAll(addRemTF, btnBox);
    return box;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  public <T> HBox beanTF(String path, String selectionPath, String itemPath,
      final Class<?> itemType, final int maxChars,
      Class<? extends Control> controlType, final String restictTo,
      T... choices) {
    HBox box = new HBox();
    Control ctrl;
    if (controlType == CheckBox.class) {
      CheckBox cb = new CheckBox();
      // POJO binding magic...
      personPA.bindBidirectional(path, cb.selectedProperty());
      ctrl = cb;
    } else if (controlType == ComboBox.class) {
      ComboBox<T> cb = new ComboBox<>(
          FXCollections.observableArrayList(choices));
      cb.setPromptText("Select");
      cb.setPrefWidth(100d);
      // POJO binding magic (due to erasure of T in
      // ObjectProperty<T> of cb.valueProperty() we need
      // to also pass in the choice class)
      personPA.bindBidirectional(path, cb.valueProperty(),
          (Class<T>) choices[0].getClass());
      ctrl = cb;
    } else if (controlType == ListView.class) {
      ListView<T> lv = new ListView<>(
          FXCollections.observableArrayList(choices));
      lv.setEditable(true);
      lv.setMaxHeight(100d);
      lv.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
      // POJO binding magic (due to erasure of T in
      // ObservableList<T> of lv.getItems() we need
      // to also pass in the choice class)
      personPA.bindContentBidirectional(path, itemPath, itemType,
          lv.getItems(), (Class<T>) choices[0].getClass(), null, null);
      if (selectionPath != null && !selectionPath.isEmpty()) {
        // POJO binding magic (due to erasure of T in
        // ReadOnlyUnbackedObservableList<T> of
        // lv.getSelectionModel().getSelectedItems() we need
        // to also pass in the choice class as well as the
        // SelectionModel<T> of lv.getSelectionModel() so that updates
        // to the ReadOnlyUnbackedObservableList<T> can be updated)
        personPA.bindContentBidirectional(selectionPath, itemPath,
            itemType, lv.getSelectionModel().getSelectedItems(),
            (Class<T>) choices[0].getClass(),
            lv.getSelectionModel(), path);
      }
      // personPA.bindBidirectional(path, lv.itemsProperty(),
      // (Class<T>) choices[0].getClass());
      ctrl = lv;
    } else if (controlType == Slider.class) {
      Slider sl = new Slider();
      sl.setShowTickLabels(true);
      sl.setShowTickMarks(true);
      sl.setMajorTickUnit(maxChars / 2);
      sl.setMinorTickCount(7);
      sl.setBlockIncrement(1);
      sl.setMax(maxChars + 1);
      sl.setSnapToTicks(true);
      // POJO binding magic...
      personPA.bindBidirectional(path, sl.valueProperty());
      ctrl = sl;
    } else if (controlType == PasswordField.class) {
      final PasswordField tf = new PasswordField() {
        @Override
        public void replaceText(int start, int end, String text) {
          if (matchTest(text)) {
            super.replaceText(start, end, text);
          }
        }

        @Override
        public void replaceSelection(String text) {
          if (matchTest(text)) {
            super.replaceSelection(text);
          }
        }

        private boolean matchTest(String text) {
          return text.isEmpty()
              || (text.matches(restictTo) && (getText() == null || getText()
                  .length() < maxChars));
        }
      };
      // POJO binding magic...
      personPA.bindBidirectional(path, tf.textProperty());
      ctrl = tf;
    } else {
      final TextField tf = controlType == PasswordField.class ? new PasswordField() {
        @Override
        public void replaceText(int start, int end, String text) {
          if (matchTest(text)) {
            super.replaceText(start, end, text);
          }
        }

        @Override
        public void replaceSelection(String text) {
          if (matchTest(text)) {
            super.replaceSelection(text);
          }
        }

        private boolean matchTest(String text) {
          return text.isEmpty()
              || (text.matches(restictTo) && (getText() == null || getText()
                  .length() < maxChars));
        }
      }
          : new TextField() {
            @Override
            public void replaceText(int start, int end, String text) {
              if (matchTest(text)) {
                super.replaceText(start, end, text);
              }
            }

            @Override
            public void replaceSelection(String text) {
              if (matchTest(text)) {
                super.replaceSelection(text);
              }
            }

            private boolean matchTest(String text) {
              return text.isEmpty()
                  || (text.matches(restictTo) && (getText() == null || getText()
                      .length() < maxChars));
            }
          };
      // POJO binding magic...
      personPA.bindBidirectional(path, tf.textProperty());
      ctrl = tf;
    }
    box.getChildren()
        .addAll(new Label(
            path
                + (selectionPath != null
                    && !selectionPath.isEmpty() ? " (items) = \n"
                    + selectionPath + " (selected) = "
View Full Code Here

                    : " = ")), ctrl);
    return box;
  }

  public HBox beanTFW(String startLabel, String endLabel, TextField... tfs) {
    HBox box = new HBox();
    box.getChildren().add(new Label(startLabel + '('));
    box.getChildren().addAll(tfs);
    box.getChildren().add(new Label(endLabel + ");"));
    return box;
  }
View Full Code Here

    hc4.addAll(l0, vc1, vc2);
    hc5.addAll(l7,l8);
    root.addAll(hc4,hc5);
    FormulaFrame.add(root);
   
     HBox hbox = new HBox(50);
     hbox.setAlignment(Pos.CENTER);
   
          VBox vbox1 = new VBox();
          vbox1.setAlignment(Pos.BOTTOM_CENTER);
          vbox1.setStyle("-fx-border-style: solid;"
                  + "-fx-border-width: 1;"
                  + "-fx-border-color: black");
         
          VBox vbox2 = new VBox(10);
          vbox2.setAlignment(Pos.CENTER);
          vbox2.setStyle("-fx-border-style: solid;"
                  + "-fx-border-width: 1;"
                  + "-fx-border-color: black");
         
          VBox vbox3 = new VBox(20);
          vbox3.setAlignment(Pos.TOP_CENTER);
          vbox3.setStyle("-fx-border-style: solid;"
                  + "-fx-border-width: 1;"
                  + "-fx-border-color: black");
     for (int i = 0; i < 5; i++)
          {
              Button bt = new Button("Button " + (i+1));
              Button bt2 = new Button("Button " + (i+1)); // unfortunately thereĀ“s no "clone" or "copy" method
              Button bt3 = new Button("Button " + (i+1));
              Pane hb = new Pane();
              HBox hb1 = new HBox();
              hb1.getChildren().add(bt2);
              hb.getChildren().add(hb1);
              vbox1.getChildren().add(bt);
              vbox2.getChildren().add(hb);
              vbox3.getChildren().add(bt3);
          }
View Full Code Here

TOP

Related Classes of javafx.scene.layout.HBox

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.