Java Code Examples for javafx.scene.control.ToggleButton#setText()

The following examples show how to use javafx.scene.control.ToggleButton#setText() . 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: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 6 votes vote down vote up
public static Tuple3<Label, InputTextField, ToggleButton> addTopLabelInputTextFieldSlideToggleButton(GridPane gridPane,
                                                                                                     int rowIndex,
                                                                                                     String title,
                                                                                                     String toggleButtonTitle) {

    InputTextField inputTextField = new InputTextField();
    ToggleButton toggleButton = new JFXToggleButton();
    toggleButton.setText(toggleButtonTitle);
    VBox.setMargin(toggleButton, new Insets(4, 0, 0, 0));

    final Tuple2<Label, VBox> topLabelWithVBox = addTopLabelWithVBox(gridPane, rowIndex, title, inputTextField, 0);

    topLabelWithVBox.second.getChildren().add(toggleButton);

    return new Tuple3<>(topLabelWithVBox.first, inputTextField, toggleButton);
}
 
Example 2
Source File: FormBuilder.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
public static ToggleButton addSlideToggleButton(GridPane gridPane, int rowIndex, String title, double top) {
    ToggleButton toggleButton = new AutoTooltipSlideToggleButton();
    toggleButton.setText(title);
    GridPane.setRowIndex(toggleButton, rowIndex);
    GridPane.setColumnIndex(toggleButton, 0);
    GridPane.setMargin(toggleButton, new Insets(top, 0, 0, 0));
    gridPane.getChildren().add(toggleButton);

    return toggleButton;
}
 
Example 3
Source File: StyleWmsLayerSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);

    // set title, size, and add scene to stage
    stage.setTitle("Style WMS Layer Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a map and add it to the map view
    ArcGISMap map = new ArcGISMap(Basemap.createImagery());
    mapView = new MapView();
    mapView.setMap(map);

    // create style toggle button, disable until layer is loaded
    ToggleButton styleToggleButton = new ToggleButton();
    styleToggleButton.setText("Toggle style");
    styleToggleButton.setDisable(true);

    // create a WMS layer
    List<String> wmsLayerNames = Collections.singletonList("fsa2017");
    String url = "http://geoint.lmic.state.mn.us/cgi-bin/wms?VERSION=1.3.0&SERVICE=WMS&REQUEST=GetCapabilities";
    wmsLayer = new WmsLayer(url, wmsLayerNames);
    wmsLayer.addDoneLoadingListener(() -> {
      if (wmsLayer.getLoadStatus() == LoadStatus.LOADED) {
        // add the layer to the map
        map.getOperationalLayers().add(wmsLayer);

        // zoom to the layer on the map
        mapView.setViewpoint(new Viewpoint(wmsLayer.getFullExtent()));

        // get styles
        List<String> styles = wmsLayer.getSublayers().get(0).getSublayerInfo().getStyles();

        // set the style when the button is toggled
        styleToggleButton.selectedProperty().addListener((observable, oldValue, newValue) -> {
          if (styleToggleButton.isSelected()) {
            wmsLayer.getSublayers().get(0).setCurrentStyle(styles.get(1));
          } else {
            // default style
            wmsLayer.getSublayers().get(0).setCurrentStyle(styles.get(0));
          }
        });

        // enable the toggle button
        styleToggleButton.setDisable(false);

      } else {
        Alert alert = new Alert(Alert.AlertType.ERROR, "Failed to load WMS layer");
        alert.show();
      }
    });
    wmsLayer.loadAsync();

    // add the map view to stack pane
    stackPane.getChildren().addAll(mapView, styleToggleButton);
    StackPane.setAlignment(styleToggleButton, Pos.TOP_LEFT);
    StackPane.setMargin(styleToggleButton, new Insets(10, 0, 0, 10));
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 4
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 5
Source File: FindReplacePane.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
	pane = new MigPane();
	findField = new CustomTextField();
	previousButton = new Button();
	nextButton = new Button();
	matchCaseButton = new ToggleButton();
	regexButton = new ToggleButton();
	findInfoLabel = new Label();
	closeButton = new Button();
	replacePane = new MigPane();
	replaceField = new CustomTextField();
	replaceButton = new Button();
	replaceAllButton = new Button();
	replaceInfoLabel = new Label();
	nOfHitCountLabel = new Label();

	//======== pane ========
	{
		pane.setLayout("insets 0,hidemode 3");
		pane.setCols("[shrink 0,fill][fill]0[fill][pref:n,fill]1px[pref:n,fill][grow,fill][fill]");
		pane.setRows("[fill]0[]");

		//---- findField ----
		findField.setPromptText(Messages.get("FindReplacePane.findField.promptText"));
		findField.setPrefColumnCount(15);
		pane.add(findField, "cell 0 0");

		//---- previousButton ----
		previousButton.setFocusTraversable(false);
		pane.add(previousButton, "cell 1 0");

		//---- nextButton ----
		nextButton.setFocusTraversable(false);
		pane.add(nextButton, "cell 2 0");

		//---- matchCaseButton ----
		matchCaseButton.setText("Aa");
		matchCaseButton.setFocusTraversable(false);
		pane.add(matchCaseButton, "cell 3 0");

		//---- regexButton ----
		regexButton.setText(".*");
		regexButton.setFocusTraversable(false);
		pane.add(regexButton, "cell 4 0");
		pane.add(findInfoLabel, "cell 5 0");

		//---- closeButton ----
		closeButton.setFocusTraversable(false);
		pane.add(closeButton, "cell 6 0");

		//======== replacePane ========
		{
			replacePane.setLayout("insets rel 0 0 0");
			replacePane.setCols("[shrink 0,fill][pref:n,fill][pref:n,fill][grow,fill]");
			replacePane.setRows("[]");

			//---- replaceField ----
			replaceField.setPromptText(Messages.get("FindReplacePane.replaceField.promptText"));
			replaceField.setPrefColumnCount(15);
			replacePane.add(replaceField, "cell 0 0");

			//---- replaceButton ----
			replaceButton.setText(Messages.get("FindReplacePane.replaceButton.text"));
			replaceButton.setFocusTraversable(false);
			replacePane.add(replaceButton, "cell 1 0");

			//---- replaceAllButton ----
			replaceAllButton.setText(Messages.get("FindReplacePane.replaceAllButton.text"));
			replaceAllButton.setFocusTraversable(false);
			replacePane.add(replaceAllButton, "cell 2 0");
			replacePane.add(replaceInfoLabel, "cell 3 0");
		}
		pane.add(replacePane, "cell 0 1 7 1");
	}

	//---- nOfHitCountLabel ----
	nOfHitCountLabel.setText(Messages.get("FindReplacePane.nOfHitCountLabel.text"));
	// JFormDesigner - End of component initialization  //GEN-END:initComponents
}
 
Example 6
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));
}