< Java FX

JavaFX - Testreszabás

Szerző: Sallai András

Copyright © Sallai András, 2023

Licenc: CC Attribution-Share Alike 4.0 International

Web: https://szit.hu

Színezés

label1.setTextFill(Color.BLUE);
label1.setTextFill(Color.color(0, 0, 0.5));
label1.setTextFill(Color.rgb(0, 0, 80));
label1.setTextFill(Color.web("#000080"));
import javafx.application.Application; import javafx.geometry.Insets; import javafx.scene.Scene; import javafx.scene.control.Label; import javafx.scene.layout.Background; import javafx.scene.layout.BackgroundFill; import javafx.scene.layout.CornerRadii; import javafx.scene.layout.StackPane; import javafx.scene.paint.Color; import javafx.stage.Stage; public class App extends Application { public static void main(String[] args) throws Exception { launch(args); } @Override public void start(Stage stage) throws Exception { StackPane root = new StackPane(); Label label1 = new Label("Valami"); label1.setTextFill(Color.AQUA); label1.setBackground( new Background( new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY) ) ); root.getChildren().add(label1); stage.setScene(new Scene(root, 400, 300)); stage.show(); } }

Szegély

label1.setBorder( new Border( new BorderStroke( Color.BLACK, BorderStrokeStyle.SOLID, null, new BorderWidths(3) ) ) );

Font

label1.setFont(new Font(40));
label1.setFont(new Font("Liberation Serif", 24));
label1.setFont(new Font("Arial", 24));

Sorok tördelése

label1.setWrapText(true);