Skip to content

Instantly share code, notes, and snippets.

@alvareztech
Created June 11, 2017 00:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alvareztech/a9780d0468c556ac5655631f380678ca to your computer and use it in GitHub Desktop.
Save alvareztech/a9780d0468c556ac5655631f380678ca to your computer and use it in GitHub Desktop.
JavaFX: Ejemplo de Label con propiedades de centrado, fuente y color
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