Java Code Examples for javafx.scene.control.Button#setManaged()

The following examples show how to use javafx.scene.control.Button#setManaged() . 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: GameBoardView.java    From metastone with GNU General Public License v2.0 6 votes vote down vote up
private void enableSummonTargets(final HumanTargetOptions targetOptions) {
	int playerId = targetOptions.getPlayerId();
	GameContext context = targetOptions.getContext();
	for (final GameAction action : targetOptions.getActionGroup().getActionsInGroup()) {
		Entity target = context.resolveSingleTarget(action.getTargetKey());
		GameToken token = getToken(target);
		Button summonHelper = playerId == 0 ? summonHelperMap1.get(token) : summonHelperMap2.get(token);
		summonHelper.setVisible(true);
		summonHelper.setManaged(true);
		EventHandler<ActionEvent> clickedHander = new EventHandler<ActionEvent>() {

			@Override
			public void handle(ActionEvent event) {
				disableTargetSelection();
				targetOptions.getActionSelectionListener().onActionSelected(action);
			}
		};
		summonHelper.setOnAction(clickedHander);
	}
}
 
Example 2
Source File: LayoutHelpers.java    From houdoku with MIT License 5 votes vote down vote up
/**
 * Set whether all Button children of the given Parent are visible.
 *
 * @param parent  the parent node
 * @param visible whether the buttons should be visible
 */
public static void setChildButtonVisible(Parent parent, boolean visible) {
    for (Node child : parent.getChildrenUnmodifiable()) {
        if (child instanceof Button) {
            Button button = (Button) child;
            button.setVisible(visible);
            button.setManaged(visible);
        } else if (child instanceof Parent) {
            setChildButtonVisible((Parent) child, visible);
        }
    }
}
 
Example 3
Source File: GameBoardView.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
private Button createSummonHelper() {
	ImageView icon = new ImageView(IconFactory.getSummonHelper());
	icon.setFitWidth(32);
	icon.setFitHeight(32);
	Button helper = new Button("", icon);
	helper.setStyle("-fx-padding: 2 2 2 2;");
	helper.setVisible(false);
	helper.setManaged(false);
	return helper;
}
 
Example 4
Source File: ActionInputPane.java    From constellation with Apache License 2.0 4 votes vote down vote up
public ActionInputPane(final PluginParameter<?> parameter) {
    field = new Button();
    String label = parameter.getStringValue();
    if (label == null || label.isEmpty()) {
        label = parameter.getName();
    }
    field.setText(label);

    String icon = parameter.getIcon();
    if (icon != null) {
        ImageView img = new ImageView(icon);
        field.setGraphic(img);
    }
    field.setManaged(parameter.isVisible());
    field.setVisible(parameter.isVisible());
    this.setManaged(parameter.isVisible());
    this.setVisible(parameter.isVisible());

    field.setOnAction(event -> {
        // Set a new Object every time so the change event fires.
        //            parameter.setObjectValue(new Object());
        parameter.fireNoChange();
    });

    parameter.addListener((final PluginParameter<?> pluginParameter, final ParameterChange change) -> {
        Platform.runLater(() -> {
            switch (change) {
                case ENABLED:
                    field.setDisable(!pluginParameter.isEnabled());
                    break;
                case VISIBLE:
                    field.setManaged(parameter.isVisible());
                    field.setVisible(parameter.isVisible());
                    this.setVisible(parameter.isVisible());
                    this.setManaged(parameter.isVisible());
                    break;
                default:
                    LOGGER.log(Level.FINE, "ignoring parameter change type {0}.", change);
                    break;
            }

        });
    });

    getChildren().add(field);
}