Java Code Examples for javafx.scene.control.Label#setLabelFor()

The following examples show how to use javafx.scene.control.Label#setLabelFor() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ConfigurationUIController.java    From jace with GNU General Public License v2.0 6 votes vote down vote up
private Node buildKeyShortcutRow(ConfigNode node, String actionName, String[] values) {
    InvokableAction actionInfo = Configuration.getInvokableActionInfo(node.subject, actionName);
    if (actionInfo == null) {
        return null;
    }
    HBox row = new HBox();
    row.getStyleClass().add("setting-row");
    Label label = new Label(actionInfo.name());
    label.getStyleClass().add("setting-keyboard-shortcut");
    label.setMinWidth(150.0);
    String value = Arrays.stream(values).collect(Collectors.joining(" or "));
    Text widget = new Text(value);
    widget.setWrappingWidth(180.0);
    widget.getStyleClass().add("setting-keyboard-value");
    widget.setOnMouseClicked((event) -> {
        editKeyboardShortcut(node, actionName, widget);
    });
    label.setLabelFor(widget);
    row.getChildren().add(label);
    row.getChildren().add(widget);
    return row;
}
 
Example 2
Source File: ConfigurationUIController.java    From jace with GNU General Public License v2.0 6 votes vote down vote up
private Node buildSettingRow(ConfigNode node, String settingName, Serializable value) {
    ConfigurableField fieldInfo = Configuration.getConfigurableFieldInfo(node.subject, settingName);
    if (fieldInfo == null) {
        return null;
    }
    HBox row = new HBox();
    row.getStyleClass().add("setting-row");
    Label label = new Label(fieldInfo.name());
    label.getStyleClass().add("setting-label");
    label.setMinWidth(150.0);
    Node widget = buildEditField(node, settingName, value);
    label.setLabelFor(widget);
    row.getChildren().add(label);
    row.getChildren().add(widget);
    return row;
}
 
Example 3
Source File: GitRepositoryDetailsPanel.java    From phoenicis with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Populates the repository details step for the git repository
 */
private void populate() {
    this.urlField = new TextField();
    this.branchField = new TextField("master");

    Label urlLabel = new Label(tr("Git-URL:"));
    urlLabel.setLabelFor(urlField);
    Label branchLabel = new Label(tr("Git-Branch:"));
    branchLabel.setLabelFor(branchField);

    GridPane grid = new GridPane();
    grid.getStyleClass().add("grid");
    grid.add(urlLabel, 0, 0);
    grid.add(urlField, 1, 0);

    grid.add(branchLabel, 0, 1);
    grid.add(branchField, 1, 1);

    this.setCenter(grid);
}
 
Example 4
Source File: DetailedSongPanel.java    From Quelea with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Add a label / input block to a panel.
 * <p>
 * @param panel the panel to add to.
 * @param labelText the label text to add to this block.
 * @param comp the component to add to this block.
 */
private void addBlock(GridPane panel, String labelText, Node comp, int i) {
    Label label = new Label(labelText);
    label.setLabelFor(comp);
    GridPane.setConstraints(label, 1, i);
    GridPane.setConstraints(comp, 2, i);
    panel.getChildren().add(label);
    panel.getChildren().add(comp);
}
 
Example 5
Source File: ClasspathRepositoryDetailsPanel.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Populates the repository details step for the classpath repository
 */
private void populate() {
    this.classpathField = new TextField();

    Label classpathLabel = new Label(tr("Classpath:"));
    classpathLabel.setLabelFor(classpathField);

    HBox content = new HBox(classpathLabel, classpathField);
    content.setId("addClasspathRepository");
    HBox.setHgrow(classpathField, Priority.ALWAYS);

    this.setCenter(content);
}
 
Example 6
Source File: ChooseRepositoryTypePanel.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Populates the content of this component
 */
private void populate() {
    choiceBox = new ComboBox<>(repositoryChoices);
    choiceBox.setPromptText(tr("Please select the repository type you want to add"));

    choiceBox.setConverter(new StringConverter<RepositoryType>() {
        @Override
        public String toString(RepositoryType repositoryType) {
            return repositoryType.getLabel();
        }

        @Override
        public RepositoryType fromString(String string) {
            return Arrays.stream(RepositoryType.values()).filter(type -> type.getLabel().equals(string)).findAny()
                    .orElse(null);
        }
    });

    choiceBox.setOnAction(
            event -> onRepositoryTypeSelection.accept(choiceBox.getSelectionModel().getSelectedItem()));

    Label choiceBoxLabel = new Label(tr("Repository type:"));
    choiceBoxLabel.setLabelFor(choiceBox);

    HBox content = new HBox(choiceBoxLabel, choiceBox);
    content.setId("repositoryTypeSelection");
    HBox.setHgrow(choiceBox, Priority.ALWAYS);

    this.setCenter(content);
}
 
Example 7
Source File: IsotopePatternPreviewDialog.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
private void organizeParameterPanel() {
  lblMergeWidth = new Label(pMergeWidth.getName());
  lblMinIntensity = new Label(pMinIntensity.getName());
  lblFormula = new Label(pFormula.getName());
  lblCharge = new Label(pCharge.getName());
  lblStatus = new Label("Status");
  setStatus("Waiting.");

  paramsPane.getChildren().remove(cmpCharge);
  paramsPane.getChildren().remove(cmpMergeWidth);
  paramsPane.getChildren().remove(cmpMinIntensity);
  paramsPane.getChildren().remove(cmpFormula);

  lblFormula.setLabelFor(cmpFormula);
  lblMinIntensity.setLabelFor(cmpMinIntensity);
  lblMergeWidth.setLabelFor(cmpMergeWidth);
  lblCharge.setLabelFor(cmpCharge);

  // cmpCharge.setPreferredSize(new Dimension(30, cmpCharge.getHeight()));
  cmpCharge.setColumns(2);

  pnlParameters.getChildren().add(lblFormula);
  pnlParameters.getChildren().add(cmpFormula);
  pnlParameters.getChildren().add(lblMinIntensity);
  pnlParameters.getChildren().add(cmpMinIntensity);
  pnlParameters.getChildren().add(lblMergeWidth);
  pnlParameters.getChildren().add(cmpMergeWidth);
  pnlParameters.getChildren().add(lblCharge);
  pnlParameters.getChildren().add(cmpCharge);
  pnlParameters.getChildren().add(lblStatus);
}
 
Example 8
Source File: DateTimeRangeInputPane.java    From constellation with Apache License 2.0 5 votes vote down vote up
/**
 * Build a single datetime picker.
 *
 * @param label
 * @param ld
 * @param h
 * @param m
 * @param s
 * @param listener
 * @return
 */
private Pane createPicker(final String label, final ChangeListener<String> changed) {
    final Label dpLabel = new Label(label);
    final DatePicker dp = new DatePicker();
    dp.setConverter(new StringConverter<LocalDate>() {
        @Override
        public String toString(final LocalDate date) {
            return date != null ? DATE_FORMATTER.format(date) : "";
        }

        @Override
        public LocalDate fromString(final String s) {
            return s != null && !s.isEmpty() ? LocalDate.parse(s, DATE_FORMATTER) : null;
        }
    });
    dpLabel.setLabelFor(dp);
    final HBox dpBox = new HBox(dpLabel, dp);
    final HBox spinnerBox = new HBox(CONTROLPANE_SPACING / 2);
    dp.maxWidthProperty().bind(spinnerBox.widthProperty().multiply(2.0 / 3.0));
    spinnerBox.getChildren().addAll(createSpinner("Hour", 0, 23, changed), createSpinner("Minute", 0, 59, changed), createSpinner("Second", 0, 59, changed));
    final VBox picker = new VBox(dpBox, spinnerBox);
    picker.setStyle("-fx-padding:4; -fx-border-radius:4; -fx-border-color: grey;");

    dp.getEditor().textProperty().addListener(changed);

    // The DatePicker has the horrible problem that you can type in the text field, but the value won't change,
    // so if you type a new date and click Go, the old date will be used, not the new date that you can see.
    // The simplest way to avoid this is to disable the text field. :-(
    dp.getEditor().setDisable(true);

    datePickers.add(dp);

    return picker;
}
 
Example 9
Source File: LineStyleEditorFactory.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setHgap(CONTROLS_DEFAULT_HORIZONTAL_SPACING);

    final Label lineStyleLabel = new Label("Line Style:");
    final ObservableList<LineStyle> lineStyles = FXCollections.observableArrayList(LineStyle.values());
    lineStyleComboBox = new ComboBox<>(lineStyles);
    final Callback<ListView<LineStyle>, ListCell<LineStyle>> cellFactory = (final ListView<LineStyle> p) -> new ListCell<LineStyle>() {
        @Override
        protected void updateItem(final LineStyle item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(item.name());
            }
        }
    };
    lineStyleComboBox.setCellFactory(cellFactory);
    lineStyleComboBox.setButtonCell(cellFactory.call(null));
    lineStyleLabel.setLabelFor(lineStyleComboBox);
    lineStyleComboBox.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    controls.addRow(0, lineStyleLabel, lineStyleComboBox);
    return controls;
}
 
Example 10
Source File: ConnectionModeEditorFactory.java    From constellation with Apache License 2.0 5 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setHgap(CONTROLS_DEFAULT_HORIZONTAL_SPACING);

    final Label connectionModeLabel = new Label("Connection Mode:");
    final ObservableList<ConnectionMode> connectionModes = FXCollections.observableArrayList(ConnectionMode.values());
    connectionModeComboBox = new ComboBox<>(connectionModes);
    final Callback<ListView<ConnectionMode>, ListCell<ConnectionMode>> cellFactory = (final ListView<ConnectionMode> p) -> new ListCell<ConnectionMode>() {
        @Override
        protected void updateItem(final ConnectionMode item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(item.name());
            }
        }
    };
    connectionModeComboBox.setCellFactory(cellFactory);
    connectionModeComboBox.setButtonCell(cellFactory.call(null));
    connectionModeLabel.setLabelFor(connectionModeComboBox);
    connectionModeComboBox.getSelectionModel().selectedItemProperty().addListener((o, n, v) -> {
        update();
    });

    controls.addRow(0, connectionModeLabel, connectionModeComboBox);
    return controls;
}
 
Example 11
Source File: DateTimeRangeInputPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
/**
 * Build the hour/minute/second part of the datetime picker.
 *
 * @param label
 * @param min
 * @param max
 * @param value
 * @param changed
 * @return
 */
private Pane createSpinner(final String label, final int min, final int max, final ChangeListener<String> changed) {
    final int NUMBER_SPINNER_WIDTH = 55;
    final String small = "-fx-font-size: 75%;";

    final Spinner<Integer> spinner = new Spinner<>(min, max, 1);
    spinner.setPrefWidth(NUMBER_SPINNER_WIDTH);

    // Create a filter to limit text entry to just numerical digits
    final NumberFormat format = NumberFormat.getIntegerInstance();
    final UnaryOperator<TextFormatter.Change> filter = c -> {
        if (c.isContentChange()) {
            final ParsePosition parsePosition = new ParsePosition(0);
            // NumberFormat evaluates the beginning of the text
            format.parse(c.getControlNewText(), parsePosition);
            if (parsePosition.getIndex() == 0 || c.getControlNewText().length() > 2
                    || parsePosition.getIndex() < c.getControlNewText().length()) {
                // reject parsing the complete text failed
                return null;
            }
        }
        return c;
    };

    // Ensure spinner is set to editable, meaning user can directly edit text, then hook in
    // a text formatter which in turn will trigger flitering of input text.
    spinner.setEditable(true);
    final TextFormatter<Integer> timeFormatter = new TextFormatter<>(new IntegerStringConverter(), 0, filter);
    spinner.getEditor().setTextFormatter(timeFormatter);

    final Label spinnerLabel = new Label(label);
    spinnerLabel.setLabelFor(spinner);
    spinnerLabel.setStyle(small);

    final VBox vbox = new VBox();
    vbox.getChildren().addAll(spinnerLabel, spinner);

    spinner.valueProperty().addListener((ObservableValue<? extends Number> observable, Number oldValue, Number newValue) -> {
        changed.changed(null, null, null);
    });

    timeSpinners.add(spinner);

    return vbox;
}
 
Example 12
Source File: DateTimeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
@Override
protected Node createEditorControls() {
    final GridPane controls = new GridPane();
    controls.setAlignment(Pos.CENTER);
    controls.setVgap(CONTROLS_DEFAULT_VERTICAL_SPACING);

    noValueCheckBox = new CheckBox(NO_VALUE_LABEL);
    noValueCheckBox.setAlignment(Pos.CENTER);
    noValueCheckBox.selectedProperty().addListener((v, o, n) -> {
        datePicker.setDisable(noValueCheckBox.isSelected());
        hourSpinner.setDisable(noValueCheckBox.isSelected());
        minSpinner.setDisable(noValueCheckBox.isSelected());
        secSpinner.setDisable(noValueCheckBox.isSelected());
        milliSpinner.setDisable(noValueCheckBox.isSelected());
        timeZoneComboBox.setDisable(noValueCheckBox.isSelected());
        update();
    });

    final ObservableList<ZoneId> timeZones = FXCollections.observableArrayList();
    ZoneId.getAvailableZoneIds().forEach(id -> {
        timeZones.add(ZoneId.of(id));
    });
    timeZoneComboBox = new ComboBox<>();
    timeZoneComboBox.setItems(timeZones.sorted(zoneIdComparator));
    final Callback<ListView<ZoneId>, ListCell<ZoneId>> cellFactory = (final ListView<ZoneId> p) -> new ListCell<ZoneId>() {
        @Override
        protected void updateItem(final ZoneId item, boolean empty) {
            super.updateItem(item, empty);
            if (item != null) {
                setText(TimeZoneUtilities.getTimeZoneAsString(currentValue == null ? null : currentValue.toLocalDateTime(), item));
            }
        }
    };

    final Label timeZoneComboBoxLabel = new Label("Time Zone:");
    timeZoneComboBoxLabel.setId(LABEL_ID);
    timeZoneComboBoxLabel.setLabelFor(timeZoneComboBoxLabel);

    timeZoneComboBox.setCellFactory(cellFactory);
    timeZoneComboBox.setButtonCell(cellFactory.call(null));
    timeZoneComboBox.getSelectionModel().select(TimeZoneUtilities.UTC);
    timeZoneComboBox.getSelectionModel().selectedItemProperty().addListener(updateTimeFromZone);

    final HBox timeZoneHbox = new HBox(timeZoneComboBoxLabel, timeZoneComboBox);
    timeZoneHbox.setSpacing(5);
    final HBox timeSpinnerContainer = createTimeSpinners();

    controls.addRow(0, timeSpinnerContainer);
    controls.addRow(1, timeZoneHbox);
    controls.addRow(2, noValueCheckBox);
    return controls;
}
 
Example 13
Source File: LanguagePanel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Create a new LanguagePanel
 */
public LanguagePanel()
{
	originalLanguage = ConfigurationSettings.getLanguage();

	if ((SettingsHandler.getGameAsProperty().get() != null) && (SettingsHandler.getGameAsProperty().get().getUnitSet() != null))
	{
		originalUnitSet = SettingsHandler.getGameAsProperty().get().getUnitSet().getDisplayName();
	}
	else
	{
		originalUnitSet = "";
	}

	VBox vbox = new VBox();

	for (LanguageChoice languageChoice: LanguageChoice.values())
	{
		ToggleButton languageButton = new RadioButton();
		languageButton.setUserData(languageChoice.getShortName());
		languageButton.setText(languageChoice.getLongName());
		languageButton.setToggleGroup(languageChoiceGroup);
		vbox.getChildren().add(languageButton);
	}

	Collection<UnitSet> unitSets = SettingsHandler.getGameAsProperty().get().getModeContext().getReferenceContext()
	                                              .getConstructedCDOMObjects(UnitSet.class);
	Collection<String> names = unitSets.stream()
	                                   .filter(Objects::nonNull)
	                                   .map(UnitSet::getDisplayName)
	                                   .collect(Collectors.toUnmodifiableList());
	ObservableList<String> unitSetNames = FXCollections.observableArrayList(names);
	unitSetType = new ChoiceBox<>();
	unitSetType.setItems(unitSetNames);
	Label unitSetLabel = new Label(LanguageBundle.getString("in_Prefs_unitSetType"));
	unitSetLabel.setLabelFor(unitSetType);
	vbox.getChildren().add(unitSetLabel);
	vbox.getChildren().add(unitSetType);

	Node restartInfo = new Text(LanguageBundle.getString("in_Prefs_restartInfo"));
	vbox.getChildren().add(restartInfo);

	this.add(GuiUtility.wrapParentAsJFXPanel(vbox));
}
 
Example 14
Source File: EditorOptionsPane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 4 votes vote down vote up
private void initComponents() {
	// JFormDesigner - Component initialization - DO NOT MODIFY  //GEN-BEGIN:initComponents
	markersTitle = new Label();
	Label strongEmphasisMarkerLabel = new Label();
	strongEmphasisMarkerField = new ChoiceBox<>();
	Label emphasisMarkerLabel = new Label();
	emphasisMarkerField = new ChoiceBox<>();
	Label bulletListMarkerLabel = new Label();
	bulletListMarkerField = new ChoiceBox<>();
	formatTitle = new Label();
	wrapLineLengthLabel = new Label();
	wrapLineLengthField = new IntSpinner();
	Label wrapLineLengthLabel2 = new Label();
	formatOnSaveCheckBox = new CheckBox();
	formatOnlyModifiedParagraphsCheckBox = new CheckBox();

	//======== this ========
	setLayout("hidemode 3");
	setCols(
		"[indent,fill]0" +
		"[fill]" +
		"[fill]" +
		"[fill]");
	setRows(
		"[]" +
		"[]" +
		"[]" +
		"[]para" +
		"[]" +
		"[]" +
		"[]" +
		"[]");

	//---- markersTitle ----
	markersTitle.setText(Messages.get("EditorOptionsPane.markersTitle.text"));
	add(markersTitle, "cell 0 0 2 1");

	//---- strongEmphasisMarkerLabel ----
	strongEmphasisMarkerLabel.setText(Messages.get("EditorOptionsPane.strongEmphasisMarkerLabel.text"));
	strongEmphasisMarkerLabel.setMnemonicParsing(true);
	add(strongEmphasisMarkerLabel, "cell 1 1");
	add(strongEmphasisMarkerField, "cell 2 1");

	//---- emphasisMarkerLabel ----
	emphasisMarkerLabel.setText(Messages.get("EditorOptionsPane.emphasisMarkerLabel.text"));
	emphasisMarkerLabel.setMnemonicParsing(true);
	add(emphasisMarkerLabel, "cell 1 2");
	add(emphasisMarkerField, "cell 2 2");

	//---- bulletListMarkerLabel ----
	bulletListMarkerLabel.setText(Messages.get("EditorOptionsPane.bulletListMarkerLabel.text"));
	bulletListMarkerLabel.setMnemonicParsing(true);
	add(bulletListMarkerLabel, "cell 1 3");
	add(bulletListMarkerField, "cell 2 3");

	//---- formatTitle ----
	formatTitle.setText(Messages.get("EditorOptionsPane.formatTitle.text"));
	add(formatTitle, "cell 0 4 2 1");

	//---- wrapLineLengthLabel ----
	wrapLineLengthLabel.setText(Messages.get("EditorOptionsPane.wrapLineLengthLabel.text"));
	wrapLineLengthLabel.setMnemonicParsing(true);
	add(wrapLineLengthLabel, "cell 1 5");
	add(wrapLineLengthField, "cell 2 5");

	//---- wrapLineLengthLabel2 ----
	wrapLineLengthLabel2.setText(Messages.get("EditorOptionsPane.wrapLineLengthLabel2.text"));
	add(wrapLineLengthLabel2, "cell 3 5");

	//---- formatOnSaveCheckBox ----
	formatOnSaveCheckBox.setText(Messages.get("EditorOptionsPane.formatOnSaveCheckBox.text"));
	add(formatOnSaveCheckBox, "cell 1 6 2 1,alignx left,growx 0");

	//---- formatOnlyModifiedParagraphsCheckBox ----
	formatOnlyModifiedParagraphsCheckBox.setText(Messages.get("EditorOptionsPane.formatOnlyModifiedParagraphsCheckBox.text"));
	add(formatOnlyModifiedParagraphsCheckBox, "cell 1 7 2 1,alignx left,growx 0");
	// JFormDesigner - End of component initialization  //GEN-END:initComponents

	// TODO set this in JFormDesigner as soon as it supports labelFor
	strongEmphasisMarkerLabel.setLabelFor(strongEmphasisMarkerField);
	emphasisMarkerLabel.setLabelFor(emphasisMarkerField);
	bulletListMarkerLabel.setLabelFor(bulletListMarkerField);
	wrapLineLengthLabel.setLabelFor(wrapLineLengthField);
}
 
Example 15
Source File: TimeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
private HBox createTimeSpinners() {
    hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
    minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
    hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
    minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
    secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
    milliSpinner.getValueFactory().setValue(0);

    final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);

    final Label hourSpinnerLabel = new Label("hr:");
    hourSpinnerLabel.setId(LABEL);
    hourSpinnerLabel.setLabelFor(hourSpinner);

    final Label minSpinnerLabel = new Label("min:");
    minSpinnerLabel.setId(LABEL);
    minSpinnerLabel.setLabelFor(minSpinner);

    final Label secSpinnerLabel = new Label("sec:");
    secSpinnerLabel.setId(LABEL);
    secSpinnerLabel.setLabelFor(secSpinner);

    final Label milliSpinnerLabel = new Label("ms:");
    milliSpinnerLabel.setId(LABEL);
    milliSpinnerLabel.setLabelFor(milliSpinner);

    hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);

    hourSpinner.setEditable(true);
    minSpinner.setEditable(true);
    secSpinner.setEditable(true);
    milliSpinner.setEditable(true);

    hourSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    minSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    secSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    milliSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });

    final VBox hourLabelNode = new VBox(5);
    hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
    final VBox minLabelNode = new VBox(5);
    minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
    final VBox secLabelNode = new VBox(5);
    secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
    final VBox milliLabelNode = new VBox(5);
    milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);

    timeSpinnerContainer.getChildren().addAll(hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);

    return timeSpinnerContainer;
}
 
Example 16
Source File: LanguagePanel.java    From pcgen with GNU Lesser General Public License v2.1 4 votes vote down vote up
/**
 * Create a new LanguagePanel
 */
public LanguagePanel()
{
	originalLanguage = ConfigurationSettings.getLanguage();

	if ((SettingsHandler.getGameAsProperty().get() != null) && (SettingsHandler.getGameAsProperty().get().getUnitSet() != null))
	{
		originalUnitSet = SettingsHandler.getGameAsProperty().get().getUnitSet().getDisplayName();
	}
	else
	{
		originalUnitSet = "";
	}

	VBox vbox = new VBox();

	for (LanguageChoice languageChoice: LanguageChoice.values())
	{
		ToggleButton languageButton = new RadioButton();
		languageButton.setUserData(languageChoice.getShortName());
		languageButton.setText(languageChoice.getLongName());
		languageButton.setToggleGroup(languageChoiceGroup);
		vbox.getChildren().add(languageButton);
	}

	Collection<UnitSet> unitSets = SettingsHandler.getGameAsProperty().get().getModeContext().getReferenceContext()
	                                              .getConstructedCDOMObjects(UnitSet.class);
	Collection<String> names = unitSets.stream()
	                                   .filter(Objects::nonNull)
	                                   .map(UnitSet::getDisplayName)
	                                   .collect(Collectors.toUnmodifiableList());
	ObservableList<String> unitSetNames = FXCollections.observableArrayList(names);
	unitSetType = new ChoiceBox<>();
	unitSetType.setItems(unitSetNames);
	Label unitSetLabel = new Label(LanguageBundle.getString("in_Prefs_unitSetType"));
	unitSetLabel.setLabelFor(unitSetType);
	vbox.getChildren().add(unitSetLabel);
	vbox.getChildren().add(unitSetType);

	Node restartInfo = new Text(LanguageBundle.getString("in_Prefs_restartInfo"));
	vbox.getChildren().add(restartInfo);

	this.add(GuiUtility.wrapParentAsJFXPanel(vbox));
}
 
Example 17
Source File: LocalDateTimeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
private HBox createTimeSpinners() {
    datePicker = new DatePicker();
    datePicker.setConverter(new LocalDateStringConverter(
            TemporalFormatting.DATE_FORMATTER, TemporalFormatting.DATE_FORMATTER));
    datePicker.getEditor().textProperty().addListener((v, o, n) -> {
        update();
    });
    datePicker.setValue(LocalDate.now());
    datePicker.valueProperty().addListener((v, o, n) -> {
        update();
    });

    hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
    minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
    hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
    minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
    secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
    milliSpinner.getValueFactory().setValue(0);

    final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);

    final Label dateLabel = new Label("Date:");
    dateLabel.setId(LABEL_ID);
    dateLabel.setLabelFor(datePicker);

    final Label hourSpinnerLabel = new Label("Hour:");
    hourSpinnerLabel.setId(LABEL_ID);
    hourSpinnerLabel.setLabelFor(hourSpinner);

    final Label minSpinnerLabel = new Label("Minute:");
    minSpinnerLabel.setId(LABEL_ID);
    minSpinnerLabel.setLabelFor(minSpinner);

    final Label secSpinnerLabel = new Label("Second:");
    secSpinnerLabel.setId(LABEL_ID);
    secSpinnerLabel.setLabelFor(secSpinner);

    final Label milliSpinnerLabel = new Label("Millis:");
    milliSpinnerLabel.setId(LABEL_ID);
    milliSpinnerLabel.setLabelFor(milliSpinner);

    hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);

    hourSpinner.setEditable(true);
    minSpinner.setEditable(true);
    secSpinner.setEditable(true);
    milliSpinner.setEditable(true);

    hourSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    minSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    secSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });
    milliSpinner.valueProperty().addListener((o, n, v) -> {
        update();
    });

    final VBox dateLabelNode = new VBox(5);
    dateLabelNode.getChildren().addAll(dateLabel, datePicker);
    final VBox hourLabelNode = new VBox(5);
    hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
    final VBox minLabelNode = new VBox(5);
    minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
    final VBox secLabelNode = new VBox(5);
    secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
    final VBox milliLabelNode = new VBox(5);
    milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);

    timeSpinnerContainer.getChildren().addAll(dateLabelNode, hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);

    return timeSpinnerContainer;
}
 
Example 18
Source File: DateTimeEditorFactory.java    From constellation with Apache License 2.0 4 votes vote down vote up
private HBox createTimeSpinners() {
    datePicker = new DatePicker();
    datePicker.setConverter(new LocalDateStringConverter(
            TemporalFormatting.DATE_FORMATTER, TemporalFormatting.DATE_FORMATTER));
    datePicker.getEditor().textProperty().addListener((v, o, n) -> {
        update();
        updateTimeZoneList();
    });
    datePicker.setValue(LocalDate.now());
    datePicker.valueProperty().addListener((v, o, n) -> {
        update();
        updateTimeZoneList();
    });

    hourSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 23));
    minSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    secSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 59));
    milliSpinner = new Spinner<>(new SpinnerValueFactory.IntegerSpinnerValueFactory(0, 999));
    hourSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getHour());
    minSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getMinute());
    secSpinner.getValueFactory().setValue(LocalTime.now(ZoneOffset.UTC).getSecond());
    milliSpinner.getValueFactory().setValue(0);

    final HBox timeSpinnerContainer = new HBox(CONTROLS_DEFAULT_VERTICAL_SPACING);

    final Label dateLabel = new Label("Date:");
    dateLabel.setId(LABEL_ID);
    dateLabel.setLabelFor(datePicker);

    final Label hourSpinnerLabel = new Label("Hour:");
    hourSpinnerLabel.setId(LABEL_ID);
    hourSpinnerLabel.setLabelFor(hourSpinner);

    final Label minSpinnerLabel = new Label("Minute:");
    minSpinnerLabel.setId(LABEL_ID);
    minSpinnerLabel.setLabelFor(minSpinner);

    final Label secSpinnerLabel = new Label("Second:");
    secSpinnerLabel.setId(LABEL_ID);
    secSpinnerLabel.setLabelFor(secSpinner);

    final Label milliSpinnerLabel = new Label("Millis:");
    milliSpinnerLabel.setId(LABEL_ID);
    milliSpinnerLabel.setLabelFor(milliSpinner);

    hourSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    minSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    secSpinner.setPrefWidth(NUMBER_SPINNER_WIDTH);
    milliSpinner.setPrefWidth(MILLIS_SPINNER_WIDTH);

    hourSpinner.setEditable(true);
    minSpinner.setEditable(true);
    secSpinner.setEditable(true);
    milliSpinner.setEditable(true);

    hourSpinner.valueProperty().addListener((o, n, v) -> {
        update();
        updateTimeZoneList();
    });
    minSpinner.valueProperty().addListener((o, n, v) -> {
        update();
        updateTimeZoneList();
    });
    secSpinner.valueProperty().addListener((o, n, v) -> {
        update();
        updateTimeZoneList();
    });
    milliSpinner.valueProperty().addListener((o, n, v) -> {
        update();
        updateTimeZoneList();
    });

    final VBox dateLabelNode = new VBox(5);
    dateLabelNode.getChildren().addAll(dateLabel, datePicker);
    final VBox hourLabelNode = new VBox(5);
    hourLabelNode.getChildren().addAll(hourSpinnerLabel, hourSpinner);
    final VBox minLabelNode = new VBox(5);
    minLabelNode.getChildren().addAll(minSpinnerLabel, minSpinner);
    final VBox secLabelNode = new VBox(5);
    secLabelNode.getChildren().addAll(secSpinnerLabel, secSpinner);
    final VBox milliLabelNode = new VBox(5);
    milliLabelNode.getChildren().addAll(milliSpinnerLabel, milliSpinner);

    timeSpinnerContainer.getChildren().addAll(dateLabelNode, hourLabelNode, minLabelNode, secLabelNode, milliLabelNode);

    return timeSpinnerContainer;
}