Java Code Examples for javafx.beans.property.SimpleBooleanProperty#addListener()

The following examples show how to use javafx.beans.property.SimpleBooleanProperty#addListener() . 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: ConnectDialogController.java    From trex-stateless-gui with Apache License 2.0 6 votes vote down vote up
@Override
public void initialize(URL url, ResourceBundle rb) {
    initializeConnections();

    isConnectionInProgress = new SimpleBooleanProperty(false);
    isConnectionInProgress.addListener(
        (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> {
            if (newValue != null) {
                mainViewContainer.setDisable(newValue);
                mainViewContainer.getScene().setCursor(newValue ? Cursor.WAIT : Cursor.DEFAULT);
            }
        }
    );

    timeoutField.textProperty().addListener((observable, oldValue, newValue) -> {
        if (!newValue.matches("\\d*")) {
            timeoutField.setText(newValue.replaceAll("[^\\d]", ""));
        }
    });
}
 
Example 2
Source File: ManagedMeshSettings.java    From paintera with GNU General Public License v2.0 5 votes vote down vote up
public MeshSettings getOrAddMesh(final Long id, final boolean isManaged) {
	if (!isManagedProperties.containsKey(id)) {
		final SimpleBooleanProperty isManagedProperty = new SimpleBooleanProperty(isManaged);
		final MeshSettings settings = new MeshSettings(globalSettings.getNumScaleLevels());
		isManagedProperty.addListener((obs, oldv, newv) -> {
			LOG.info("Managing settings for mesh id {}? {}", id, newv);
			bindBidirectionalToGlobalSettings(settings, newv);
		});
		bindBidirectionalToGlobalSettings(settings, isManaged);
		isManagedProperties.put(id, isManagedProperty);
		individualSettings.put(id, settings);
	}
	return individualSettings.get(id);
}
 
Example 3
Source File: App.java    From java-ml-projects with Apache License 2.0 5 votes vote down vote up
private void initVariables() {
	selectedModel = new SimpleObjectProperty<>();
	outputReady = new SimpleBooleanProperty();
	zoomValue = new SimpleIntegerProperty(5);
	showActivationGrid = new SimpleBooleanProperty();
	showChannelGrid = new SimpleBooleanProperty();
	showLayerListener = (b, o, n) -> showLayer();
	showActivationGrid.addListener(showLayerListener);
	showChannelGrid.addListener(showLayerListener);
}
 
Example 4
Source File: Graph.java    From fxgraph with Do What The F*ck You Want To Public License 4 votes vote down vote up
public Graph(Model model) {
	this.model = model;

	nodeGestures = new NodeGestures(this);
	useNodeGestures = new SimpleBooleanProperty(true);
	useNodeGestures.addListener((obs, oldVal, newVal) -> {
		if (newVal) {
			model.getAllCells().forEach(cell -> nodeGestures.makeDraggable(getGraphic(cell)));
		} else {
			model.getAllCells().forEach(cell -> nodeGestures.makeUndraggable(getGraphic(cell)));
		}
	});

	pannableCanvas = new PannableCanvas();
	viewportGestures = new ViewportGestures(pannableCanvas);
	useViewportGestures = new SimpleBooleanProperty(true);
	useViewportGestures.addListener((obs, oldVal, newVal) -> {
		final Parent parent = pannableCanvas.parentProperty().get();
		if (parent == null) {
			return;
		}
		if (newVal) {
			parent.addEventHandler(MouseEvent.MOUSE_PRESSED, viewportGestures.getOnMousePressedEventHandler());
			parent.addEventHandler(MouseEvent.MOUSE_DRAGGED, viewportGestures.getOnMouseDraggedEventHandler());
			parent.addEventHandler(ScrollEvent.ANY, viewportGestures.getOnScrollEventHandler());
		} else {
			parent.removeEventHandler(MouseEvent.MOUSE_PRESSED, viewportGestures.getOnMousePressedEventHandler());
			parent.removeEventHandler(MouseEvent.MOUSE_DRAGGED, viewportGestures.getOnMouseDraggedEventHandler());
			parent.removeEventHandler(ScrollEvent.ANY, viewportGestures.getOnScrollEventHandler());
		}
	});
	pannableCanvas.parentProperty().addListener((obs, oldVal, newVal) -> {
		if (oldVal != null) {
			oldVal.removeEventHandler(MouseEvent.MOUSE_PRESSED, viewportGestures.getOnMousePressedEventHandler());
			oldVal.removeEventHandler(MouseEvent.MOUSE_DRAGGED, viewportGestures.getOnMouseDraggedEventHandler());
			oldVal.removeEventHandler(ScrollEvent.ANY, viewportGestures.getOnScrollEventHandler());
		}
		if (newVal != null) {
			newVal.addEventHandler(MouseEvent.MOUSE_PRESSED, viewportGestures.getOnMousePressedEventHandler());
			newVal.addEventHandler(MouseEvent.MOUSE_DRAGGED, viewportGestures.getOnMouseDraggedEventHandler());
			newVal.addEventHandler(ScrollEvent.ANY, viewportGestures.getOnScrollEventHandler());
		}
	});

	graphics = new HashMap<>();

	addEdges(getModel().getAllEdges());
	addCells(getModel().getAllCells());
}