Skip to content

Instantly share code, notes, and snippets.

@abd3lraouf
Created December 29, 2015 23:12
Show Gist options
  • Save abd3lraouf/f6c530e65b13d7e849c8 to your computer and use it in GitHub Desktop.
Save abd3lraouf/f6c530e65b13d7e849c8 to your computer and use it in GitHub Desktop.
Always rectangle
package Junit;
import javafx.application.*;
import javafx.scene.*;
import javafx.scene.layout.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.stage.*;
public class AlwaysRectangle extends Application {
public static void main(String[] args) {
launch(args);
}
@Override
public void start(Stage primaryStage) throws Exception {
Rectangle rectangle = new Rectangle(500, 250);
rectangle.setFill(Color.TRANSPARENT);
rectangle.setStroke(Color.BLACK);
rectangle.widthProperty().bind(primaryStage.widthProperty().subtract(100));
rectangle.heightProperty().bind(rectangle.widthProperty().divide(2));
StackPane stackPane = new StackPane();
stackPane.getChildren().addAll(rectangle);
Scene scene = new Scene(stackPane);
primaryStage.setScene(scene);
primaryStage.show();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment