Advertisement
Guest User

WieISGayApp

a guest
Oct 30th, 2014
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. /*
  2. * To change this license header, choose License Headers in Project Properties.
  3. * To change this template file, choose Tools | Templates
  4. * and open the template in the editor.
  5. */
  6. package wieisgay;
  7.  
  8. import java.util.HashMap;
  9. import java.util.Map;
  10. import java.util.Random;
  11. import javafx.application.Application;
  12. import javafx.event.ActionEvent;
  13. import javafx.event.EventHandler;
  14. import javafx.scene.Scene;
  15. import javafx.scene.control.Button;
  16. import javafx.scene.control.Label;
  17. import javafx.scene.layout.HBox;
  18. import javafx.scene.layout.StackPane;
  19. import javafx.stage.Stage;
  20.  
  21. /**
  22. *
  23. * @author Cedric
  24. */
  25. public class WieIsGay extends Application {
  26. Random random;
  27. Map mapje;
  28. Label veld;
  29. HBox hbox;
  30. @Override
  31. public void start(Stage primaryStage) {
  32. hbox = new HBox();
  33. veld = new Label();
  34.  
  35.  
  36. mapje = new HashMap<>();
  37. mapje.put(0, "Simon");
  38. mapje.put(1, "Ward");
  39. mapje.put(2, "Anthony");
  40. mapje.put(3, "Rudolf");
  41. mapje.put(4, "Sooi");
  42. mapje.put(5, "Cedric");
  43.  
  44. random = new Random();
  45.  
  46. Button btn = new Button();
  47. btn.setText("Wie is gay?");
  48. btn.setOnAction(new EventHandler<ActionEvent>() {
  49.  
  50. @Override
  51. public void handle(ActionEvent event) {
  52.  
  53. veld.setText(mapje.get(random.nextInt(6)) + " is gay!");
  54. }
  55. });
  56.  
  57. StackPane root = new StackPane();
  58. hbox.getChildren().addAll(btn, veld);
  59. root.getChildren().add(hbox);
  60. root.getChildren().add(veld);
  61.  
  62. Scene scene = new Scene(root, 500, 20);
  63.  
  64. primaryStage.setTitle("Wie is gay?");
  65. primaryStage.setScene(scene);
  66. primaryStage.show();
  67. }
  68.  
  69. /**
  70. * @param args the command line arguments
  71. */
  72. public static void main(String[] args) {
  73. launch(args);
  74. }
  75.  
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement