Advertisement
Guest User

Untitled

a guest
May 24th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. package application;
  2.  
  3.  
  4. import javafx.application.Application;
  5. import javafx.fxml.FXMLLoader;
  6. import javafx.scene.Parent;
  7. import javafx.scene.Scene;
  8. import javafx.stage.Stage;
  9.  
  10. public class Main extends Application {
  11.  
  12. @Override
  13. public void start(Stage primaryStage) throws Exception{
  14. Parent root = FXMLLoader.load(getClass().getResource("Layout_play.fxml"));
  15. primaryStage.setTitle("Test");
  16. primaryStage.setFullScreen(true);
  17. primaryStage.setScene(new Scene(root, 1280, 720));
  18. primaryStage.show();
  19. }
  20.  
  21.  
  22. public static void main(String[] args) {
  23. launch(args);
  24. }
  25. }
  26.  
  27. public class PlayController {
  28.  
  29. @FXML
  30. private Label label;
  31. @FXML
  32. private TextField textfield;
  33.  
  34. @FXML
  35. private BackgroundImage myBI= new BackgroundImage(new Image("/Background.png",1280,720,false,true),
  36. BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
  37. BackgroundSize.DEFAULT);
  38.  
  39.  
  40.  
  41. @FXML
  42. private void handleButtonAction(ActionEvent event) {
  43. System.out.println("You clicked me!");
  44. label.setText("Hello " + textfield.getText());
  45. }
  46. }
  47.  
  48. <BorderPane fx:controller="application.PlayController" xmlns:fx="http://javafx.com/fxml"
  49. prefHeight="200" prefWidth="320" >
  50.  
  51. <top>
  52. <Text text="java-Buddy"/>
  53. </top>
  54. <left>
  55. <Label text="Who are you?"/>
  56. </left>
  57. <center>
  58. <TextField id="textfield" fx:id="textfield"/>
  59. </center>
  60. <right>
  61. <Button id="button" text="Click Me!"
  62. onAction="#handleButtonAction" fx:id="button"/>
  63. </right>
  64. <bottom>
  65. <Label id="label" fx:id="label"/>
  66. </bottom>
  67.  
  68. </BorderPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement