package test; import javafx.application.Application; import javafx.event.EventHandler; import javafx.scene.Group; import javafx.scene.Scene; import javafx.scene.input.MouseEvent; import javafx.scene.paint.Color; import javafx.scene.shape.Circle; import javafx.scene.shape.Rectangle; import javafx.stage.Stage; public class ClipChange extends Application { @Override public void start(Stage stage) { stage.setTitle("Clip change"); final Group root = new Group(); Scene scene = new Scene(root, 300, 300); scene.setFill(Color.LIGHTGREEN); final BlaSkin blaSkin = new BlaSkin(); blaSkin.setOnMouseClicked(new EventHandler() { @Override public void handle(MouseEvent event) { blaSkin.changeSize(150, 150); } }); root.getChildren().add(blaSkin); stage.setScene(scene); stage.show(); } public class BlaSkin extends Circle { private Rectangle rect; public BlaSkin() { super(100, 100, 100, Color.RED); rect = new Rectangle(100, 100); setClip(rect); } public void changeSize(double x, double y) { rect.setWidth(x); rect.setHeight(y); } } /** * @param args the command line arguments */ public static void main(String[] args) { Application.launch(args); } }