Java Code Examples for javafx.scene.control.TextField.setPrefColumnCount()

The following are Jave code examples for showing how to use setPrefColumnCount() of the javafx.scene.control.TextField class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: CalendarFX   File: GoogleEntryDetailsView.java   Source Code and License Vote up 5 votes
private GoogleEntryReminderItem(GoogleEntryReminder reminder) {
    this.reminder = requireNonNull(reminder);

    methodCombo = new ComboBox<>();
    methodCombo.getItems().setAll(RemindMethod.values());
    methodCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    methodCombo.valueProperty().bindBidirectional(reminder.methodProperty());
    methodCombo.setConverter(new StringConverter<RemindMethod>() {
        @Override
        public String toString(RemindMethod object) {
            return object.getName();
        }

        @Override
        public RemindMethod fromString(String string) {
            for (RemindMethod method : RemindMethod.values()) {
                if (method.getName().equals(string)) {
                    return method;
                }
            }
            return null;
        }
    });

    Integer minutes = reminder.getMinutes();
    TimeUnit unit = TimeUnit.MINUTES;
    if (minutes != null) {
        if (minutes % 1440 == 0) {
            unit = TimeUnit.DAYS;
            minutes = minutes / 1400;
        } else if (minutes % 60 == 0) {
            unit = TimeUnit.HOURS;
            minutes = minutes / 60;
        }
    }

    valueTxt = new TextField();
    valueTxt.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    valueTxt.setPrefColumnCount(5);
    valueTxt.setText(minutes == null ? "" : minutes.toString());
    valueTxt.textProperty().addListener(obs -> updateMinutes());

    unitCombo = new ComboBox<>();
    unitCombo.getItems().setAll(TimeUnit.MINUTES, TimeUnit.HOURS, TimeUnit.DAYS);
    unitCombo.disableProperty().bind(entry.getCalendar().readOnlyProperty());
    unitCombo.setValue(unit);
    unitCombo.valueProperty().addListener(obs -> updateMinutes());

    removeIcon = new Label();
    removeIcon.getStyleClass().add("button-icon");
    removeIcon.setGraphic(new FontAwesome().create(FontAwesome.Glyph.TRASH_ALT));
    removeIcon.setOnMouseClicked(evt -> removeReminder(reminder));
    removeIcon.disableProperty().bind(entry.getCalendar().readOnlyProperty());

    HBox.setHgrow(removeIcon, Priority.NEVER);
    setAlignment(Pos.CENTER_LEFT);
    getChildren().addAll(methodCombo, valueTxt, unitCombo, removeIcon);
    getStyleClass().add("notification-item");
}
 
Example 2
Project: file-transfer   File: SendNetPane.java   Source Code and License Vote up 4 votes
private void createIPTextField() {
    id = new TextField();
    addTextFieldCharLimit(id, 4);
    id.setPrefColumnCount(4);
}