Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package sample;
- import javafx.application.Application;
- import javafx.fxml.FXMLLoader;
- import javafx.geometry.Insets;
- import javafx.geometry.Pos;
- import javafx.scene.Group;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.scene.canvas.Canvas;
- import javafx.scene.canvas.GraphicsContext;
- import javafx.scene.effect.BlendMode;
- import javafx.scene.layout.*;
- import javafx.scene.paint.Color;
- import javafx.scene.shape.Rectangle;
- import javafx.stage.Stage;
- import javafx.scene.shape.*;
- import javafx.scene.text.*;
- public class Main extends Application {
- @Override
- public void start(Stage primaryStage) throws Exception{
- Group root = new Group();
- Scene scene = new Scene(root, 800, 600);
- primaryStage.setTitle("Test");
- root.getChildren().addAll(addVBox());
- primaryStage.setScene(scene);
- primaryStage.show();
- }
- public HBox addHBox(){
- HBox hbox = new HBox();
- hbox.setPadding(new Insets(15, 12, 15, 12));
- hbox.setSpacing(10);
- hbox.setStyle("-fx-background-color: #336699;");
- return hbox;
- }
- public GridPane addGridPane(){
- GridPane grid = new GridPane();
- grid.setHgap(10);
- grid.setVgap(10);
- grid.setPadding(new Insets(0,10,0,10));
- //monday
- StackPane mondayStack = new StackPane();
- Rectangle moRect = new Rectangle(30,70);
- moRect.setArcHeight(10);
- moRect.setArcWidth(10);
- moRect.setFill(Color.DARKSLATEBLUE);
- Text moText = new Text("Mo");
- moText.setFont(Font.font("Arial", FontPosture.ITALIC, 14));
- moText.setFill(Color.WHEAT);
- moText.setTextAlignment(TextAlignment.RIGHT);
- mondayStack.getChildren().addAll(moRect, moText);
- grid.add(mondayStack, 1, 1);
- //tuesday
- StackPane tuesdayStack = new StackPane();
- Rectangle tuRect = new Rectangle(30,70);
- tuRect.setArcHeight(10);
- tuRect.setArcWidth(10);
- tuRect.setFill(Color.DARKSLATEBLUE);
- Text tuText = new Text("Tu");
- tuText.setFont(Font.font("Arial", FontPosture.ITALIC, 14));
- tuText.setFill(Color.WHEAT);
- tuText.setTextAlignment(TextAlignment.RIGHT);
- tuesdayStack.getChildren().addAll(tuRect, tuText);
- grid.add(tuesdayStack, 1, 2);
- //wednesday
- StackPane wednesdayStack = new StackPane();
- Rectangle weRect = new Rectangle(30,60);
- weRect.setArcHeight(10);
- weRect.setArcWidth(10);
- weRect.setFill(Color.DARKSLATEBLUE);
- Text weText = new Text("We");
- weText.setFont(Font.font("Arial", FontPosture.ITALIC, 14));
- weText.setFill(Color.WHEAT);
- weText.setTextAlignment(TextAlignment.RIGHT);
- wednesdayStack.getChildren().addAll(weRect, weText);
- grid.add(wednesdayStack, 1, 3);
- //thursday
- StackPane thursdayStack = new StackPane();
- Rectangle thRect = new Rectangle(30,50);
- thRect.setArcHeight(10);
- thRect.setArcWidth(10);
- thRect.setFill(Color.DARKSLATEBLUE);
- Text thText = new Text("Th");
- thText.setFont(Font.font("Arial", FontPosture.ITALIC, 14));
- thText.setTextAlignment(TextAlignment.RIGHT);
- thText.setFill(Color.WHEAT);
- thursdayStack.getChildren().addAll(thRect, thText);
- grid.add(thursdayStack, 1, 4);
- return grid;
- }
- public VBox addVBox(){
- VBox vBox = new VBox();
- vBox.getChildren().addAll( addHBox() , addGridPane());
- return vBox;
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement