Created
February 3, 2015 11:42
-
-
Save kineticz/16ceb337a8b6d41b9c52 to your computer and use it in GitHub Desktop.
How can I anchor text at the center?
This file contains hidden or 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
| package je3.thread; | |
| import javafx.application.Application; | |
| import javafx.geometry.Insets; | |
| import javafx.scene.Scene; | |
| import javafx.scene.layout.Pane; | |
| import javafx.scene.text.Text; | |
| import javafx.stage.Stage; | |
| /** | |
| * Text seemed to be anchored at the bottom left corner. | |
| * See screenshot here: http://i60.tinypic.com/2mnnmrn.jpg | |
| */ | |
| public class ShowText extends Application { | |
| @Override | |
| public void start(Stage primaryStage) throws Exception { | |
| Pane pane = new Pane(); | |
| pane.setPadding(new Insets(0, 0, 0, 0)); | |
| Text text1 = new Text(20, 20, "Programming fun"); | |
| // text1.setFont(Font.font("Courier", BOLD, FontPosture.ITALIC, 15)); | |
| Text text2 = new Text(30, 30, "Programming fun"); | |
| Text text3 = new Text(40, 40, "Programming fun"); | |
| // text3.setFill(Color.RED); | |
| // text3.setUnderline(true); | |
| pane.getChildren().addAll(text1, text2,text3); | |
| Scene scene = new Scene(pane); | |
| primaryStage.setScene(scene); | |
| primaryStage.show(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment