Uma das vantagens do JavaFX é o velho UI toolkits que permite você aplicar efeitos, gradientes e animações aos nodes da sua scene. Vamos aplicar algumas modificações no projeto MyShapes.
JavaFX é capaz de interpolar cores, e assim fazer o efeito gradiente. Gradiente tem as opções de radial ou linear. No momento o código está assim:
package sample;
import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.layout.StackPane;
import javafx.scene.paint.Color;
import javafx.scene.shape.Ellipse;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class MyShapes extends Application {
@Override
public void start(Stage stage) throws Exception {
Ellipse ellipse = new Ellipse(110, 70);
ellipse.setFill(Color.LIGHTBLUE);
Text text = new Text("Minhas Formas");
text.setFont(new Font("Arial Bold", 24));
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(ellipse, text);
Scene scene = new Scene(stackPane, 350, 230, Color.LIGHTYELLOW);
stage.setTitle("Minhas Formas com JavaFX");
stage.setScene(scene);
stage.show();
}
public static void main(String[] args){
launch(args);
}
}
Fonte: The Definitive Guide to Modern Java Clients with JavaFX





Deixe um comentário