Skip to content

Instantly share code, notes, and snippets.

Avatar

Dirk Lemmermann dlemmermann

View GitHub Profile
View LinkedCirclesGraphic.java
private void applyClip() {
ReadOnlyObjectProperty<Bounds> boundsProperty = layoutBoundsProperty();
Rectangle rect = new Rectangle();
rect.setManaged(false);
rect.layoutXProperty().bind(Bindings.createDoubleBinding(() -> boundsProperty.get().getMinX(), boundsProperty));
rect.layoutYProperty().bind(Bindings.createDoubleBinding(() -> boundsProperty.get().getMinY(), boundsProperty));
rect.widthProperty().bind(Bindings.createDoubleBinding(() -> boundsProperty.get().getWidth(), boundsProperty));
rect.heightProperty().bind(Bindings.createDoubleBinding(() -> boundsProperty.get().getHeight(), boundsProperty));
rect.setFill(Color.BLACK);
@dlemmermann
dlemmermann / MaskedView.java
Last active Aug 28, 2018
This code shows how you can use clipping in JavaFX in combination with the alpha channel to implement fade in / out effects (not animations).
View MaskedView.java
import javafx.beans.property.DoubleProperty;
import javafx.beans.property.SimpleDoubleProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.Node;
import javafx.scene.control.Control;
import javafx.scene.control.Skin;
public class MaskedView extends Control {
public MaskedView(Node content) {
@dlemmermann
dlemmermann / ShadowScrollPane.java
Created Jun 19, 2018
A JavaFX ScrollPane with a drop shadow effect at the top when the user scrolls down.
View ShadowScrollPane.java
package uk.co.senapt.desktop.shell;
import javafx.beans.property.BooleanProperty;
import javafx.beans.property.SimpleBooleanProperty;
import javafx.geometry.Insets;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.Region;
import javafx.scene.shape.Rectangle;
@dlemmermann
dlemmermann / VisibleManagedDemo.java
Created Jun 18, 2018
A little demo showing how the "visible" and "managed" property can be used to make a node disappear in such a way that the layout pane / container can reclaim the space previously occupied by the now invisible node.
View VisibleManagedDemo.java
package uk.co.senapt.desktop;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.control.CheckBox;
import javafx.scene.control.Label;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;