Skip to content

Instantly share code, notes, and snippets.

@kineticz
Created February 3, 2015 14:28
Show Gist options
  • Select an option

  • Save kineticz/0233746ed84f22b805db to your computer and use it in GitHub Desktop.

Select an option

Save kineticz/0233746ed84f22b805db to your computer and use it in GitHub Desktop.
package je3.thread;
import javafx.application.Application;
import javafx.geometry.Insets;
import javafx.scene.Scene;
import javafx.scene.layout.Pane;
import javafx.scene.layout.StackPane;
import javafx.scene.shape.Circle;
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("Programming fun");
StackPane textPane1 = new StackPane();
textPane1.getChildren().add(text1);
textPane1.setLayoutX(200 - textPane1.getLayoutBounds().getWidth() / 2);
textPane1.setLayoutY(200 - textPane1.getLayoutBounds().getHeight() / 2);
Text text2 = new Text(300, 300, "Programming fun");
Text text3 = new Text(400, 400, "Programming fun");
Circle circle1 = new Circle(200, 200, 2);
Circle circle2 = new Circle(300, 300, 2);
Circle circle3 = new Circle(400, 400, 2);
pane.getChildren().addAll(textPane1, text2,text3, circle1, circle2, circle3);
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