JavaFX: Ejemplo de Label con propiedades de centrado, fuente y color
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javafx.application.Application; | |
import javafx.geometry.Pos; | |
import javafx.scene.Scene; | |
import javafx.scene.control.Label; | |
import javafx.scene.layout.VBox; | |
import javafx.scene.paint.Color; | |
import javafx.scene.text.Font; | |
import javafx.stage.Stage; | |
public class Main extends Application { | |
public static void main(String[] args) { | |
launch(args); | |
} | |
@Override | |
public void start(Stage primaryStage) throws Exception { | |
Label label = new Label("Hola"); | |
label.setFont(new Font("Arial", 50)); | |
label.setTextFill(Color.web("#0076a3")); | |
label.setAlignment(Pos.CENTER); | |
label.setPrefSize(Double.MAX_VALUE, Double.MAX_VALUE); | |
VBox vBox = new VBox(); | |
vBox.getChildren().add(label); | |
vBox.setAlignment(Pos.CENTER); | |
Scene scene = new Scene(vBox, 400, 400); | |
primaryStage.setScene(scene); | |
primaryStage.show(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment