Solution:
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.paint.Color;
import javafx.scene.text.Font;
import javafx.scene.text.FontPosture;
import javafx.scene.text.FontWeight;
import javafx.scene.text.Text;
import javafx.stage.Stage;
public class TextJava extends Application {
@Override
public void start(Stage primaryStage) {
Pane pane = new Pane();
Font font = Font.font("Times New Roman", FontWeight.BOLD, FontPosture.ITALIC, 22);
Text[] texts = new Text[5];
for(int i = 0; i < texts.length; i++) {
texts[i] = new Text(20 * i, 50, "JAVA");
texts[i].setFont(font);
texts[i].setFill(new Color(Math.random(), Math.random(), Math.random(), Math.random()));
texts[i].setRotate(90);
pane.getChildren().add(texts[i]);
}
Scene scene = new Scene(pane, 100, 100);
primaryStage.setTitle("JAVA with color");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
No comments:
Post a Comment