DoubleProperty x = new SimpleDoubleProperty(); DoubleProperty y = new SimpleDoubleProperty(); Timeline timeline = new Timeline( new KeyFrame(Duration.seconds(0), new KeyValue(x, 0), timeline.setAutoReverse(true); timeline.setCycleCount(Timeline.INDEFINITE); gc.setFill(Color.FORESTGREEN); gc.fillOval( x.doubleValue(), y.doubleValue(), D, stage.setScene( new Scene( new Group( stage.show();
/** * Default Constructor. * * @param opacity the opacity to use [0.0-1.0]. */ public AbstractBaseColor(final Double opacity) { super(); this.opacityProperty.set(opacity); }
/** * @return the width */ public Double getWidth() { return width.get(); }
public void start(Stage primaryStage) { Button btn = new Button(); btn.setText("Show Sliding In Alert Dialog"); btn.setOnAction(event -> { Alert alert = new Alert(AlertType.CONFIRMATION); alert.setTitle("Confirmation Dialog"); final DoubleProperty yProperty = new SimpleDoubleProperty(); yProperty.addListener((ob,n,n1)->alert.setY(n1.doubleValue())); Timeline timeIn = new Timeline(); timeIn.getKeyFrames().add( new KeyFrame(Duration.seconds(1.5), e->buttonBar.setDisable(false), new KeyValue(yProperty, yEnd,Interpolator.EASE_BOTH))); timeIn.play(); primaryStage.close(); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show();
private void _prepareShow(boolean autohide) { if (canShow) { dialogStage.initModality(Modality.APPLICATION_MODAL); dialogStage.setScene(scene); dialogStage.initOwner(ViewStructure.primaryStage()); final DoubleProperty x = new SimpleDoubleProperty(); x.bind(ViewStructure.primaryStage().xProperty().add(ViewStructure.primaryStage().widthProperty().subtract(dialogStage.widthProperty()).divide(2))); final DoubleProperty y = new SimpleDoubleProperty(); y.bind(ViewStructure.primaryStage().yProperty().add(ViewStructure.primaryStage().heightProperty().subtract(dialogStage.heightProperty()).divide(3))); x.addListener((ChangeListener<Number>) (obs, oldValue, newValue) -> dialogStage.setX(newValue.doubleValue())); Timeline tm = new Timeline(new KeyFrame(Duration.millis(1500), e -> { dialogStage.hide(); })); tm.play();
ObservableList<TablePosition> selectedCells = FXCollections.observableArrayList(); Button multi = new Button("Multi-select"); multi.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { multi.setText((multi.getText().equals("Multi-select"))?"Single-select":"Multi-select"); selectedCells.clear(); Scene scene = new Scene(root, 300, 300); primaryStage.setTitle("multi select table test"); primaryStage.setScene(scene); primaryStage.show(); private final StringProperty desc = new SimpleStringProperty(); private final DoubleProperty amount = new SimpleDoubleProperty(); desc.set(dsc); amount.set(amt);
Button copy = new Button("Copy"); copy.setOnAction(e -> System.out.println(copy(table))); copy.disableProperty().bind(Bindings.isEmpty(table.getSelectionModel().getSelectedItems())); root.setBottom(copy); Scene scene = new Scene(root, 600, 600); primaryStage.setScene(scene); primaryStage.show(); private final StringProperty name = new SimpleStringProperty(); private final DoubleProperty price = new SimpleDoubleProperty() ;
root.setStyle("-fx-background-color: null;"); DoubleProperty stageX = new SimpleDoubleProperty(); stageX.addListener((observable, oldValue, newValue) -> { if (newValue != null && newValue.doubleValue() != Double.NaN) { stage.setX(newValue.doubleValue()); slideLeft.setOnFinished(event -> { slideLeft.jumpTo(Duration.ZERO); stage.centerOnScreen(); stageX.setValue(stage.getX()); }); root.setOnMouseExited(event -> slideLeft.play()); stage.setScene(new Scene(root, W, 100, Color.BURLYWOOD)); stage.centerOnScreen(); stageX.set(stage.getX());
cm.setY(yIni); final DoubleProperty yProperty = new SimpleDoubleProperty(yIni); yProperty.addListener((ob,n,n1)->cm.setY(n1.doubleValue())); Timeline timeIn = new Timeline(); timeIn.getKeyFrames().add( new KeyFrame(Duration.seconds(0.5), new KeyValue(yProperty, yEnd, Interpolator.EASE_BOTH))); timeIn.play(); primaryStage.setTitle("Moving Popup"); primaryStage.setScene(scene); primaryStage.show();
Group root = new Group(); Scene scene = new Scene(root, 400, 300, Color.BLACK); primaryStage.setTitle("JavaFX Scene Graph Demo"); final DoubleProperty leftEdgeOpacity = new SimpleDoubleProperty(0); final DoubleProperty rightEdgeOpacity = new SimpleDoubleProperty(0); ); Button btnForward = new Button(); btnForward.setText(">"); btnForward.setOnAction(new EventHandler<ActionEvent>() { @Override public void handle(ActionEvent event) { Timeline timeline = new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(leftEdgeOpacity, 0)), new KeyFrame(Duration.ZERO, new KeyValue(rightEdgeOpacity, 0)), root.getChildren().add(pane); root.getChildren().add(btnForward); primaryStage.setScene(scene); primaryStage.show();
Button button = new Button("Grow"); ObjectProperty<Color> color = new SimpleObjectProperty<>(Color.RED); DoubleProperty size = new SimpleDoubleProperty(50); DoubleProperty fontSize = new SimpleDoubleProperty(12); DoubleProperty rotate = new SimpleDoubleProperty(0); StringProperty text = button.textProperty(); BooleanProperty large = new SimpleBooleanProperty(false); Timeline timeline = new Timeline(); button.setOnAction(e -> { timeline.getKeyFrames().clear(); timeline.getKeyFrames().add(new KeyFrame(Duration.seconds(1), new KeyValue(text, "Grow"), new KeyValue(size, 80), }); StringProperty colorAsString = new SimpleStringProperty(); colorAsString.bind(Bindings.createStringBinding(() -> toWebColor(color.get()), color)); primaryStage.setScene(scene); primaryStage.show();
private DoubleProperty fontSize = new SimpleDoubleProperty(10); private IntegerProperty blues = new SimpleIntegerProperty(50); Button btn = new Button("click me, I change color"); btn.setOnAction((evt)->{blues.set(blues.get()+20);});//max? Label lbl = new Label("I'm a label"); TextArea ta = new TextArea("Lots of text can be typed\nand even number 1234567890"); Scene scene = new Scene(root, 300, 250); fontSize.bind(scene.widthProperty().add(scene.heightProperty()).divide(50)); child.styleProperty().bind(Bindings.concat("-fx-font-size: ", fontSize.asString(), ";" ,"-fx-base: rgb(100,100,",blues.asString(),");")); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show();
label.setStyle(String.format("-fx-padding: 5px; -fx-background-radius: 5px; -fx-background-color: lightblue;")); DoubleProperty opacity = new SimpleDoubleProperty(); opacity.addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> source, Number oldValue, Number newValue) { label.setStyle(String.format("-fx-padding: 5px; -fx-background-radius: 5px; -fx-background-color: rgba(255, 0, 0, %f)", newValue.doubleValue())); final Timeline flashAnimation = new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(opacity, 1)), new KeyFrame(Duration.millis(500), new KeyValue(opacity, 0))); flashAnimation.setCycleCount(Animation.INDEFINITE); flashAnimation.setAutoReverse(true); stage.setScene(scene); stage.show();
final Group group = new Group(); final Scene scene = new Scene(group, 500, 500, Color.WHITE); stage.setScene(scene); stage.setTitle("Circles"); stage.show(); DoubleProperty angle = new SimpleDoubleProperty(); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(2), new KeyValue(angle, 360))); timeline.setCycleCount(Animation.INDEFINITE); timeline.play(); Rotate rotate = new Rotate(0, 250, 250); circle.getTransforms().add(rotate); rotate.angleProperty().bind(angle.add(360.0 * i / 5)); group.getChildren().add(circle);
final DoubleProperty percentOfTimeUsed = new SimpleDoubleProperty(0); final Timeline timer = new Timeline( new KeyFrame( Duration.ZERO, new KeyValue(percentOfTimeUsed, 0)), root.setTop(progressBar); Button answer = new Button("Answer"); answer.setOnAction(ae -> restart());// the on answer handler Button skip = new Button("Skip"); skip.setOnAction(ae -> restart());// the skip question handler root.setCenter(mainContent); timer.setOnFinished(ae -> restart());// the end of timer handler primaryStage.setScene(new Scene(root)); primaryStage.show(); void restart() { timer.stop(); timer.playFromStart(); } void pause() { timer.pause(); }
Scene scene = new Scene(root, 300, 300); primaryStage.setTitle("Filter table test"); primaryStage.setScene(scene); primaryStage.show(); private final StringProperty desc = new SimpleStringProperty(); private final DoubleProperty amount = new SimpleDoubleProperty(); desc.set(dsc); amount.set(amt);
Button button = new Button("Show notification"); button.setOnAction(e -> { Popup window = new Popup(); StackPane content = new StackPane(new Label("Notification")); DoubleProperty y = new SimpleDoubleProperty(startPos); Timeline timeline = new Timeline(new KeyFrame(Duration.seconds(1), new KeyValue(y, endPos))); y.addListener((obs, oldValue, newValue) -> window.setY(newValue.doubleValue())); timeline.play(); window.setX(primaryScreenBounds.getMaxX() - 120); window.show(primaryStage); primaryStage.setScene(new Scene(root, 350, 120)); primaryStage.show();
@Override public void start(Stage primaryStage) { StackPane root = new StackPane(); root.setStyle("-fx-background-color: null;"); root.setPadding(new Insets(10)); DoubleProperty doubleProperty = new SimpleDoubleProperty(0); Region region = new Region(); region.styleProperty().bind(Bindings .concat("-fx-background-radius:20; -fx-background-color: rgba(56, 176, 209, ") .concat(doubleProperty) .concat(");")); region.setEffect(new DropShadow(10, Color.GREY)); Slider slider = new Slider(0, 1, .3); doubleProperty.bind(slider.valueProperty()); root.getChildren().addAll(region, slider); primaryStage.initStyle(StageStyle.TRANSPARENT); Scene scene = new Scene(root, 300, 250); scene.setFill(Color.TRANSPARENT); primaryStage.setTitle("Hello World!"); primaryStage.setScene(scene); primaryStage.show(); }
ColorInput input = new ColorInput(); blendEffect.setTopInput(input); Button btn = new Button("Inversion Animation"); input.widthProperty().bind(btn.widthProperty()); input.heightProperty().bind(btn.heightProperty()); btn.setEffect(blendEffect); btn.setStyle("-fx-body-color: orange;"); DoubleProperty brightness = new SimpleDoubleProperty(0); input.paintProperty().bind(Bindings.createObjectBinding(() -> Color.BLACK.interpolate(Color.WHITE, brightness.get()), brightness)); Timeline timeline = new Timeline( new KeyFrame(Duration.ZERO, new KeyValue(brightness, 0d)), new KeyFrame(Duration.seconds(1), new KeyValue(brightness, 1d)) ); timeline.setOnFinished(evt -> timeline.setRate(-timeline.getRate())); btn.setOnAction((ActionEvent event) -> { primaryStage.setScene(scene); primaryStage.show();
DoubleProperty opacity = new SimpleDoubleProperty(); Timeline timeline = new Timeline( new KeyFrame(Duration.seconds(0), new KeyValue(opacity, 1) timeline.setAutoReverse(true); timeline.setCycleCount(Timeline.INDEFINITE); gc.setFill(Color.CORNSILK); gc.fillRect(0, 0, W, H); gc.setFill(Color.FORESTGREEN.deriveColor(0, 1, 1, opacity.get())); gc.fillOval( W/2, stage.setScene( new Scene( new Group( stage.show();