Advertisement
Guest User

Untitled

a guest
Oct 18th, 2018
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.88 KB | None | 0 0
  1. package petrescue;
  2.  
  3. import javafx.application.Application;
  4. import static javafx.application.Application.launch;
  5. import javafx.event.ActionEvent;
  6. import javafx.event.EventHandler;
  7. import javafx.scene.Group;
  8. import javafx.scene.Scene;
  9. import javafx.scene.control.Button;
  10. import javafx.scene.control.CheckBox;
  11. import javafx.scene.control.Label;
  12. import javafx.scene.control.Menu;
  13. import javafx.scene.control.MenuBar;
  14. import javafx.scene.control.MenuItem;
  15. import javafx.scene.control.PasswordField;
  16. import javafx.scene.control.TextArea;
  17. import javafx.scene.control.TextField;
  18. import javafx.scene.image.Image;
  19. import javafx.scene.image.ImageView;
  20. import javafx.scene.layout.StackPane;
  21. import javafx.scene.text.Font;
  22. import javafx.scene.text.Text;
  23. import javafx.stage.Stage;
  24.  
  25. /**
  26. *
  27. * @author Wouter
  28. */
  29. public class Main extends Application{
  30.  
  31.  
  32. /**
  33. * @param args the command line arguments
  34. */
  35.  
  36. public static void main(String[] args) {
  37. Application.launch(args);
  38. }
  39.  
  40. public void start(final Stage primaryStage) {
  41.  
  42. StackPane root1 = new StackPane();
  43. StackPane root2 = new StackPane();
  44. StackPane root3 = new StackPane();
  45. StackPane root4 = new StackPane();
  46. StackPane root5 = new StackPane();
  47. StackPane root6 = new StackPane();
  48. StackPane root7 = new StackPane();
  49.  
  50. final Scene scene1 = new Scene(root1, 400, 600);
  51. final Scene scene2 = new Scene(root2, 400, 600);
  52. final Scene scene3 = new Scene(root3, 400, 600);
  53. final Scene scene4 = new Scene(root4, 400, 600);
  54. final Scene scene5 = new Scene(root5, 400, 600);
  55. final Scene scene6 = new Scene(root6, 400, 600);
  56. final Scene scene7 = new Scene(root7, 400, 600);
  57.  
  58. Menu menuFile = new Menu("Navigation");
  59. MenuBar menuBar = new MenuBar();
  60. MenuItem menu1 = new MenuItem("Search");
  61. MenuItem menu2 = new MenuItem("Profile");
  62. MenuItem menu3 = new MenuItem("UserProfile");
  63. MenuItem menu4 = new MenuItem("Login");
  64. MenuItem menu5 = new MenuItem("Matches");
  65. MenuItem menu6 = new MenuItem("Registration");
  66. MenuItem menu7 = new MenuItem("Settings");
  67. menuFile.getItems().addAll(menu1, menu2, menu3, menu4, menu5, menu6, menu7);
  68. menuBar.getMenus().addAll(menuFile);
  69. menuBar.setTranslateY(-288);
  70.  
  71. //Begin Swipe page FXML
  72. //Like button settings
  73. Button likeButton = new Button();
  74. likeButton.setMinWidth(200);
  75. likeButton.setMinHeight(50);
  76. likeButton.setText("Like");
  77. likeButton.setTranslateY(275);
  78. likeButton.setTranslateX(-100);
  79. likeButton.setStyle("-fx-background-color: #4aef58");
  80.  
  81. likeButton.setOnAction(new EventHandler<ActionEvent>() {
  82. @Override
  83. public void handle(ActionEvent event) {
  84. System.out.println("Liked");
  85. }
  86. });
  87.  
  88. //Dislike button settings
  89. Button dislikeButton = new Button();
  90. dislikeButton.setMinWidth(200);
  91. dislikeButton.setMinHeight(50);
  92. dislikeButton.setText("Dislike");
  93. dislikeButton.setTranslateY(275);
  94. dislikeButton.setTranslateX(100);
  95. dislikeButton.setStyle("-fx-background-color: #efb849");
  96.  
  97. dislikeButton.setOnAction(new EventHandler<ActionEvent>() {
  98. @Override
  99. public void handle(ActionEvent event) {
  100. System.out.println("Disliked");
  101. }
  102. });
  103.  
  104. //Name of the pet
  105. Text name = new Text();
  106. name.setText("Carl bouncher");
  107. name.setTranslateY(80);
  108. name.setTranslateX(-120);
  109. name.setStyle("-fx-font-weight: bold; -fx-font-size: 20");
  110.  
  111. Image img = new Image(getClass().getResourceAsStream("img.jpg"));
  112.  
  113. //Age of the pet
  114. Text age = new Text();
  115. age.setText("3 years old");
  116. age.setTranslateY(110);
  117. age.setTranslateX(-120);
  118. age.setStyle("-fx-font-size: 14");
  119.  
  120. //Breed of the pet
  121. Text breed = new Text();
  122. breed.setText("Goldador");
  123. breed.setTranslateY(130);
  124. breed.setTranslateX(-120);
  125. breed.setStyle("-fx-font-size: 14; -fx-text-fill: white");
  126.  
  127. ImageView imageView = new ImageView(img);
  128.  
  129. //Setting the position of the image
  130. //setting the fit height and width of the image view
  131. //Setting the preserve ratio of the image view
  132. imageView.setPreserveRatio(true);
  133. imageView.setTranslateY(-120);
  134. imageView.setFitHeight(400);
  135. imageView.setFitWidth(400);
  136.  
  137. root1.getChildren().addAll(name, age, breed, likeButton, dislikeButton, imageView, menuBar);
  138. //root1.setStyle("-fx-background-color: #535656; -fx-text-fill: white");
  139. //End swipe page
  140. //Begin Profile page
  141.  
  142. Button btn = new Button();
  143. btn.setText("Done!");
  144. btn.setTranslateX(150);
  145. btn.setTranslateY(200);
  146.  
  147. Text nameText = new Text ("name");
  148. nameText.setTranslateX(-150);
  149. nameText.setTranslateY(-150);
  150.  
  151. Text locationText = new Text ("location");
  152. locationText.setTranslateX(-150);
  153. locationText.setTranslateY(-120);
  154.  
  155. TextField nameTextField = new TextField();
  156. nameTextField.setPromptText("Enter your name");
  157. nameTextField.setMaxWidth(200);
  158. nameTextField.setTranslateX(100);
  159. nameTextField.setTranslateY(-150);
  160.  
  161. TextField locationTextField = new TextField();
  162. locationTextField.setPromptText("Enter your location");
  163. locationTextField.setMaxWidth(200);
  164. locationTextField.setTranslateX(100);
  165. locationTextField.setTranslateY(-120);
  166.  
  167. Text pageText = new Text ("Profile Page");
  168.  
  169.  
  170. root2.getChildren().addAll(btn,nameText,pageText,locationText,nameTextField,locationTextField);
  171. //End Profile page
  172. //Begin user profile Page
  173. Text genderText = new Text ("gender");
  174. genderText.setTranslateX(-150);
  175. genderText.setTranslateY(-90);
  176.  
  177. Text ageText = new Text ("age");
  178. ageText.setTranslateX(-150);
  179. ageText.setTranslateY(-60);
  180.  
  181. Text maxDistance = new Text ("Distance");
  182. maxDistance.setTranslateX(-150);
  183. maxDistance.setTranslateY(30);
  184.  
  185. Text interestText = new Text ("Interested In");
  186. interestText.setTranslateX(-150);
  187. interestText.setTranslateY(0);
  188.  
  189. TextField maxDistanceTextField = new TextField();
  190. maxDistanceTextField.setPromptText("Maximum distance for a match");
  191. maxDistanceTextField.setMaxWidth(200);
  192. maxDistanceTextField.setTranslateX(100);
  193. maxDistanceTextField.setTranslateY(30);
  194.  
  195. TextField interestedTextField = new TextField();
  196. interestedTextField.setPromptText("Pets you are interested in");
  197. interestedTextField.setMaxWidth(200);
  198. interestedTextField.setTranslateX(100);
  199. interestedTextField.setTranslateY(0);
  200.  
  201. TextField genderTextField = new TextField();
  202. genderTextField.setPromptText("gender");
  203. genderTextField.setMaxWidth(100);
  204. genderTextField.setTranslateX( - 50);
  205. genderTextField.setTranslateY(-90);
  206.  
  207. TextField ageTextField = new TextField();
  208. ageTextField.setPromptText("age");
  209. ageTextField.setMaxWidth(50);
  210. ageTextField.setTranslateX(100 - 75);
  211. ageTextField.setTranslateY(-60);
  212.  
  213. root3.getChildren().addAll(ageText,genderText,genderTextField,ageTextField,maxDistance,interestText,maxDistanceTextField,interestedTextField);
  214. //End UserProfile Page
  215. //Begin Login page
  216. Label username=new Label("username");
  217. Label password=new Label("password");
  218. TextField usernameText=new TextField();
  219. PasswordField passwordText=new PasswordField();
  220. Text text1 = new Text();
  221. text1.setText("Pet Rescue");
  222. text1.setFont(Font.font("Arial", 50));
  223.  
  224. usernameText.setMaxWidth(200);
  225. passwordText.setMaxWidth(200);
  226.  
  227.  
  228. Button btn6 = new Button();
  229. btn6.setText("log in");
  230. btn6.setMaxWidth(100);
  231.  
  232. btn6.setTranslateX(50);
  233. btn6.setTranslateY(40);
  234. username.setTranslateX(-150);
  235. username.setTranslateY(-100);
  236. password.setTranslateX(-150);
  237. password.setTranslateY(-25);
  238. usernameText.setTranslateY(-100);
  239. passwordText.setTranslateY(-25);
  240. text1.setTranslateY(-200);
  241.  
  242. root4.getChildren().addAll(text1, btn6, username, password, usernameText, passwordText);
  243. //End Login page
  244.  
  245. //Begin Matches page
  246.  
  247. Text Title = new Text();
  248. Title.setText("Matches");
  249. Title.setTranslateY(-270);
  250. Title.setTranslateX(-150);
  251. Title.setStyle("-fx-font-weight: bold; -fx-font-size: 20");
  252.  
  253. Button contact = new Button("Contact Shelter");
  254. contact.setTranslateX(100);
  255. contact.setTranslateY(-200);
  256.  
  257. Text petName = new Text();
  258. petName.setText("Carl bouncher");
  259. petName.setTranslateY(-200);
  260. petName.setTranslateX(-130);
  261. petName.setStyle("-fx-font-weight: bold; -fx-font-size: 13");
  262.  
  263.  
  264. root5.getChildren().addAll(contact, petName, Title);
  265. //End Matches page
  266.  
  267. //Begin registration page
  268. Label registrationUsername = new Label("username");
  269. Label registrationPassword = new Label("password");
  270. Label registrationEmail = new Label("E-mail");
  271. TextField registrationUsernameText = new TextField();
  272. TextField emailText = new TextField();
  273. PasswordField registrationPasswordText = new PasswordField();
  274.  
  275. Text titleText = new Text();
  276. titleText.setText("Pet Rescue");
  277. titleText.setFont(Font.font("Arial", 50));
  278.  
  279. Text registrationText = new Text();
  280. registrationText.setText("Registration");
  281. registrationText.setFont(Font.font("Arial", 18));
  282.  
  283. registrationUsernameText.setMaxWidth(200);
  284. emailText.setMaxWidth(200);
  285. registrationPasswordText.setMaxWidth(200);
  286.  
  287.  
  288. Button btn1 = new Button();
  289. btn1.setText("Submit");
  290. btn1.setMaxWidth(100);
  291.  
  292. btn1.setTranslateX(-15);
  293. btn1.setTranslateY(100);
  294. registrationUsername.setTranslateX(-150);
  295. registrationUsername.setTranslateY(-100);
  296. registrationPassword.setTranslateX(-150);
  297. registrationPassword.setTranslateY(-25);
  298. registrationEmail.setTranslateX(-150);
  299. registrationEmail.setTranslateY(50);
  300. registrationUsernameText.setTranslateY(-100);
  301. registrationPasswordText.setTranslateY(-25);
  302. emailText.setTranslateY(50);
  303. titleText.setTranslateY(-200);
  304. registrationText.setTranslateY(-150);
  305.  
  306. root6.getChildren().addAll(titleText, btn1, registrationUsername, registrationPassword, registrationUsernameText, registrationPasswordText, emailText, registrationEmail, registrationText);
  307. //End registration page
  308. //Begin settings page
  309.  
  310. Button resetPassword = new Button();
  311. resetPassword.setText("Reset password");
  312. resetPassword.setTranslateX(-120);
  313. resetPassword.setTranslateY(200);
  314.  
  315. Button resetEmail = new Button();
  316. resetEmail.setText("Reset email");
  317. resetEmail.setTranslateX(0);
  318. resetEmail.setTranslateY(200);
  319.  
  320. Button logOut = new Button();
  321. logOut.setText("Log out");
  322. logOut.setTranslateX(100);
  323. logOut.setTranslateY(200);
  324.  
  325. CheckBox showLocationCheckBox = new CheckBox ("Show location");
  326. showLocationCheckBox.setSelected(true);
  327. showLocationCheckBox.setTranslateX(-85);
  328. showLocationCheckBox.setTranslateY(-120);
  329.  
  330. Text pageText1 = new Text ("Settings");
  331.  
  332. root7.getChildren().addAll(logOut, resetPassword, resetEmail, pageText1,showLocationCheckBox);
  333. //End settings page
  334. //Begin Navigation
  335. menu1.setOnAction(new EventHandler<ActionEvent>() {
  336.  
  337. @Override
  338. public void handle(ActionEvent event) {
  339. primaryStage.setScene(scene1);
  340. }
  341. });
  342.  
  343. menu2.setOnAction(new EventHandler<ActionEvent>() {
  344.  
  345. @Override
  346. public void handle(ActionEvent event) {
  347. primaryStage.setScene(scene2);
  348. }
  349. });
  350.  
  351. menu3.setOnAction(new EventHandler<ActionEvent>() {
  352.  
  353. @Override
  354. public void handle(ActionEvent event) {
  355. primaryStage.setScene(scene3);
  356. }
  357. });
  358.  
  359. menu4.setOnAction(new EventHandler<ActionEvent>() {
  360.  
  361. @Override
  362. public void handle(ActionEvent event) {
  363. primaryStage.setScene(scene4);
  364. }
  365. });
  366.  
  367. menu5.setOnAction(new EventHandler<ActionEvent>() {
  368.  
  369. @Override
  370. public void handle(ActionEvent event) {
  371. primaryStage.setScene(scene5);
  372. }
  373. });
  374.  
  375. menu6.setOnAction(new EventHandler<ActionEvent>() {
  376.  
  377. @Override
  378. public void handle(ActionEvent event) {
  379. primaryStage.setScene(scene6);
  380. }
  381. });
  382.  
  383. menu7.setOnAction(new EventHandler<ActionEvent>() {
  384.  
  385. @Override
  386. public void handle(ActionEvent event) {
  387. primaryStage.setScene(scene7);
  388. }
  389. });
  390.  
  391.  
  392.  
  393.  
  394.  
  395. primaryStage.setScene(scene1);
  396. primaryStage.show();
  397.  
  398. //END navigation
  399. }
  400.  
  401.  
  402. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement