Advertisement
Guest User

Untitled

a guest
Feb 12th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 11.09 KB | None | 0 0
  1. package sample;
  2.  
  3. import javafx.application.Application;
  4. import javafx.application.Platform;
  5. import javafx.beans.value.ChangeListener;
  6. import javafx.beans.value.ObservableValue;
  7. import javafx.scene.Scene;
  8. import javafx.scene.control.*;
  9. import javafx.scene.effect.DropShadow;
  10. import javafx.scene.image.Image;
  11. import javafx.scene.image.ImageView;
  12. import javafx.scene.input.MouseEvent;
  13. import javafx.scene.layout.*;
  14. import javafx.scene.paint.Color;
  15. import javafx.scene.paint.ImagePattern;
  16. import javafx.scene.text.Font;
  17. import javafx.scene.text.Text;
  18. import javafx.stage.Stage;
  19. import javafx.stage.WindowEvent;
  20.  
  21. import java.time.LocalDate;
  22.  
  23. public class Main extends Application {
  24.     public static DropShadow borderGlow = new DropShadow();
  25.     public static Stage stage;
  26.     public static int padd=100;
  27.  
  28.     @Override
  29.     public void start(Stage primaryStage) throws Exception{
  30.         stage = primaryStage;
  31.         borderGlow.setOffsetY(0f);
  32.         borderGlow.setOffsetX(0f);
  33.         borderGlow.setColor(Color.CORNFLOWERBLUE);
  34.         borderGlow.setWidth(40);
  35.         borderGlow.setHeight(40);
  36.         AnchorPane mainPane = new AnchorPane();
  37.         mainPane.setPrefHeight(795);
  38.         mainPane.setPrefWidth(1089);
  39.         mainPane.setStyle("-fx-background-color: #ccfbff;");
  40.         //titlepane
  41.         AnchorPane titlePane = new AnchorPane();
  42.         titlePane.setPrefHeight(136);
  43.         titlePane.setPrefWidth(1089);
  44.         titlePane.setLayoutX(299);
  45.         titlePane.setLayoutY(26);
  46.         titlePane.setStyle("-fx-background-color: #ffffff;");
  47.         AnchorPane.setTopAnchor(titlePane, 0.0);
  48.         AnchorPane.setBottomAnchor(titlePane, 659.0);
  49.         AnchorPane.setLeftAnchor(titlePane, 0.0);
  50.         AnchorPane.setRightAnchor(titlePane, 0.0);
  51.         //title text
  52.         Text title = new Text();
  53.         title.setText("TRIP\n");
  54.         title.setLayoutX(200);
  55.         title.setLayoutY(42);
  56.         Font f = new Font("System Bold", 26);
  57.         title.setFont(f);
  58.         //image
  59.         Image img = new Image("logo.png");
  60.         ImageView imgv = new ImageView(img);
  61.         imgv.setFitHeight(90);
  62.         imgv.setFitWidth(90);
  63.         imgv.setLayoutX(50);
  64.         imgv.setLayoutY(20);
  65.         titlePane.getChildren().addAll(title, imgv);
  66.         //login
  67.         TextField userName = new TextField();
  68.         userName.setLayoutX(890);
  69.         userName.setLayoutY(70);
  70.         userName.setPrefHeight(35);
  71.         userName.setPrefWidth(200);
  72.         userName.setEffect(borderGlow);
  73.         userName.setPromptText("Username");
  74.         userName.setText("username");
  75.         PasswordField passWord = new PasswordField();
  76.         passWord.setLayoutX(1100);
  77.         passWord.setLayoutY(70);
  78.         passWord.setPrefHeight(35);
  79.         passWord.setPrefWidth(200);
  80.         passWord.setEffect(borderGlow);
  81.         passWord.setPromptText("Password");
  82.         passWord.setText("");
  83.         Button login = new Button("Login");
  84.         login.setLayoutX(1305);
  85.         login.setLayoutY(68);
  86.         // search
  87.         AnchorPane searchBg=new AnchorPane();
  88.         searchBg.setLayoutX(13);
  89.         searchBg.setLayoutY(212);
  90.         searchBg.setPrefHeight(470);
  91.         searchBg.setPrefWidth(1089);
  92.         searchBg.setStyle(" -fx-background-image: url('bg.png');-fx-background-size: 1400 470;");
  93.         searchBg.getStylesheets().add(Main.class.getResource("table.css").toExternalForm());
  94.         //searchBg.setStyle("-fx-background-color: yellow;");
  95.         AnchorPane.setLeftAnchor(searchBg, 0.0);
  96.         AnchorPane.setRightAnchor(searchBg, 0.0);
  97.         TabPane tp = new TabPane();
  98.         tp.setLayoutX(padd+83);
  99.         tp.setLayoutY(82);
  100.         tp.setPrefHeight(283);
  101.         tp.setPrefWidth(950);
  102. //        tp.setStyle("-fx-background-color: red;");
  103.         //tp.setTabClosingPolicy();
  104.         Tab hotelTab = new Tab();
  105.         hotelTab.setText("Hotels");
  106.         AnchorPane hotelPane = new AnchorPane();
  107.         hotelPane.setPrefHeight(244);
  108.         hotelPane.setPrefWidth(950);
  109.         hotelPane.setStyle("-fx-background-color: #ccfbff;");
  110.         TextField htf1 = new TextField();
  111.         htf1.setLayoutX(padd+25);
  112.         htf1.setLayoutY(81);
  113.         htf1.setEffect(borderGlow);
  114.         Text ht1=new Text("Destination or hotel name:");
  115.         ht1.setLayoutX(padd+25);
  116.         ht1.setLayoutY(65);
  117.         ht1.setEffect(borderGlow);
  118.         DatePicker hdp1=new DatePicker();
  119.         hdp1.setLayoutX(padd+237);
  120.         hdp1.setLayoutY(81);
  121.         hdp1.setPrefHeight(31);
  122.         hdp1.setPrefWidth(178);
  123.         hdp1.setEffect(borderGlow);
  124.         hdp1.setValue(LocalDate.now());
  125.         DatePicker hdp2=new DatePicker();
  126.         hdp2.setLayoutX(padd+431);
  127.         hdp2.setLayoutY(81);
  128.         hdp2.setPrefHeight(31);
  129.         hdp2.setPrefWidth(175);
  130.         hdp2.setEffect(borderGlow);
  131.         hdp2.setValue(LocalDate.now().plusDays(2));
  132.         Slider adult=new Slider(1,5,1);
  133.         adult.setLayoutX(padd+645);
  134.         adult.setLayoutY(54);
  135.         adult.setEffect(borderGlow);
  136.         adult.setShowTickLabels(true);
  137.         adult.setShowTickMarks(true);
  138.         adult.setBlockIncrement(1);
  139.         adult.setMajorTickUnit(1);
  140.         adult.setMinorTickCount(0);
  141.         Slider child=new Slider(1,5,1);
  142.         child.setLayoutX(padd+645);
  143.         child.setLayoutY(105);
  144.         child.setEffect(borderGlow);
  145.         child.setBlockIncrement(1);
  146.         child.setMajorTickUnit(1);
  147.         child.setMinorTickCount(0);
  148.         child.setShowTickLabels(true);
  149.         child.setShowTickMarks(true);
  150.         child.setBlockIncrement(1);
  151.         Text ht2=new Text("Check in");
  152.         ht2.setLayoutX(padd+237);
  153.         ht2.setLayoutY(66);
  154.         ht2.setEffect(borderGlow);
  155.         Text ht3=new Text("Check out");
  156.         ht3.setLayoutX(padd+431);
  157.         ht3.setLayoutY(66);
  158.         ht3.setEffect(borderGlow);
  159.         Text ht4=new Text("Adults");
  160.         ht4.setLayoutX(padd+645);
  161.         ht4.setLayoutY(44);
  162.         ht4.setEffect(borderGlow);
  163.         adult.valueProperty().addListener(new ChangeListener<Number>() {
  164.             @Override
  165.             public void changed(ObservableValue<? extends Number> observable, //
  166.                                 Number oldValue, Number newValue) {
  167.                 ht4.setText("Adults : "+(int)Math.floor(newValue.doubleValue()));
  168.             }
  169.         });
  170.         Text ht5=new Text("Children");
  171.         ht5.setLayoutX(padd+645);
  172.         ht5.setLayoutY(97);
  173.         ht5.setEffect(borderGlow);
  174.         child.valueProperty().addListener(new ChangeListener<Number>() {
  175.             @Override
  176.             public void changed(ObservableValue<? extends Number> observable, //
  177.                                 Number oldValue, Number newValue) {
  178.                 ht5.setText("Childs : "+(int)Math.floor(newValue.doubleValue()));
  179.             }
  180.         });
  181.         Button hbutton = new Button("Search");
  182.         hbutton.setLayoutX(padd+645);
  183.         hbutton.setLayoutY(163);
  184.         hbutton.setPrefHeight(41);
  185.         hbutton.setPrefWidth(135);
  186.         hotelPane.getChildren().addAll(htf1,ht1,hdp1,hdp2,adult,child,ht2,ht3,ht4,ht5,hbutton);
  187.         hotelTab.setContent(hotelPane);
  188.         //hotel
  189.         Tab flightTab = new Tab();
  190.         flightTab.setText("" +
  191.                 "" +
  192.                 "Flight");
  193.         AnchorPane flightPane = new AnchorPane();
  194.         flightPane.setPrefHeight(244);
  195.         flightPane.setPrefWidth(950);
  196.         flightPane.setStyle("-fx-background-color: #ccfbff;");
  197.         TextField ftf1 = new TextField();
  198.         ftf1.setLayoutX(padd+25);
  199.         ftf1.setLayoutY(81);
  200.         ftf1.setPrefHeight(31);
  201.         ftf1.setPrefWidth(140);
  202.         ftf1.setEffect(borderGlow);
  203.         Text ft1=new Text("From");
  204.         ft1.setLayoutX(padd+25);
  205.         ft1.setLayoutY(65);
  206.         ft1.setEffect(borderGlow);
  207.         DatePicker fdp1=new DatePicker();
  208.         fdp1.setLayoutX(padd+493);
  209.         fdp1.setLayoutY(81);
  210.         fdp1.setPrefHeight(31);
  211.         fdp1.setPrefWidth(141);
  212.         fdp1.setEffect(borderGlow);
  213.         fdp1.setValue(LocalDate.now());
  214.         Slider fchild=new Slider();
  215.         fchild.setLayoutX(padd+700);
  216.         fchild.setLayoutY(143);
  217.         fchild.setPrefHeight(18);
  218.         fchild.setPrefWidth(116);
  219.         fchild.setEffect(borderGlow);
  220.         Text ft2=new Text("To");
  221.         ft2.setLayoutX(padd+184);
  222.         ft2.setLayoutY(66);
  223.         ft2.setEffect(borderGlow);
  224.         Text ft3=new Text("Return");
  225.         ft3.setLayoutX(padd+493);
  226.         ft3.setLayoutY(66);
  227.         ft3.setEffect(borderGlow);
  228.         Text ft4=new Text("Children");
  229.         ft4.setLayoutX(padd+700);
  230.         ft4.setLayoutY(135);
  231.         ft4.setEffect(borderGlow);
  232.         TextField ftf2 = new TextField();
  233.         ftf2.setLayoutX(padd+182);
  234.         ftf2.setLayoutY(81);
  235.         ftf2.setPrefHeight(31);
  236.         ftf2.setPrefWidth(146);
  237.         ftf2.setEffect(borderGlow);
  238.         Text ft5=new Text("Depart");
  239.         ft5.setLayoutX(padd+344);
  240.         ft5.setLayoutY(66);
  241.         ft5.setEffect(borderGlow);
  242.         DatePicker fdp2=new DatePicker();
  243.         fdp2.setLayoutX(padd+344);
  244.         fdp2.setLayoutY(82);
  245.         fdp2.setPrefHeight(31);
  246.         fdp2.setPrefWidth(132);
  247.         fdp2.setEffect(borderGlow);
  248.         fdp2.setValue(LocalDate.now().plusDays(2));
  249.         Text ft6=new Text("Adults");
  250.         ft6.setLayoutX(padd+553);
  251.         ft6.setLayoutY(137);
  252.         ft6.setEffect(borderGlow);
  253.         Slider fadult=new Slider();
  254.         fadult.setLayoutX(padd+553);
  255.         fadult.setLayoutY(147);
  256.         fadult.setPrefHeight(18);
  257.         fadult.setPrefWidth(113);
  258.         fadult.setEffect(borderGlow);
  259.         ComboBox fcb = new ComboBox();
  260.         fcb.setLayoutX(padd+662);
  261.         fcb.setLayoutY(81);
  262.         fcb.setPrefWidth(150);
  263.         fcb.getItems().add("Economy");
  264.         fcb.getItems().add("Business");
  265.         fcb.getItems().add("First");
  266.         fcb.getSelectionModel().select("Economy");
  267.         fcb.setEffect(borderGlow);
  268.         Text ft7=new Text("Class");
  269.         ft7.setLayoutX(padd+662);
  270.         ft7.setLayoutY(64);
  271.         ft7.setEffect(borderGlow);
  272.         Button fbutton = new Button("Search");
  273.         fbutton.setLayoutX(padd+675);
  274.         fbutton.setLayoutY(183);
  275.         fbutton.setPrefHeight(41);
  276.         fbutton.setPrefWidth(135);
  277.         flightPane.getChildren().addAll(ftf1,ftf2,ft1,fdp1,fchild,fadult,ft2,ft3,ft4,ft5,ft6,ft7,fdp2,fcb,fbutton);
  278.         flightTab.setContent(flightPane);
  279.         tp.getTabs().addAll(hotelTab,flightTab);
  280.         searchBg.getChildren().addAll(tp);
  281.         mainPane.getChildren().addAll(titlePane, userName, passWord, login,searchBg);
  282.         mainPane.getStylesheets().add(Main.class.getResource("button.css").toExternalForm());
  283.         Scene scene = new Scene(mainPane);
  284.         stage.setScene(scene);
  285.         stage.setTitle("Football Club Management");
  286.         stage.show();
  287. //        stage.getIcons().add(new Image("icon.png"));
  288.         stage.setOnCloseRequest((WindowEvent t) -> {
  289.             Platform.exit();
  290.             System.exit(0);
  291.         });
  292.     }
  293.  
  294.  
  295.     public static void main(String[] args) {
  296.         launch(args);
  297.     }
  298. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement