Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package application;
- import javafx.application.Application;
- import javafx.fxml.FXMLLoader;
- import javafx.scene.Parent;
- import javafx.scene.Scene;
- import javafx.stage.Stage;
- public class Main extends Application {
- @Override
- public void start(Stage primaryStage) throws Exception{
- Parent root = FXMLLoader.load(getClass().getResource("Layout_play.fxml"));
- primaryStage.setTitle("Test");
- primaryStage.setFullScreen(true);
- primaryStage.setScene(new Scene(root, 1280, 720));
- primaryStage.show();
- }
- public static void main(String[] args) {
- launch(args);
- }
- }
- public class PlayController {
- @FXML
- private Label label;
- @FXML
- private TextField textfield;
- @FXML
- private BackgroundImage myBI= new BackgroundImage(new Image("/Background.png",1280,720,false,true),
- BackgroundRepeat.REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.DEFAULT,
- BackgroundSize.DEFAULT);
- @FXML
- private void handleButtonAction(ActionEvent event) {
- System.out.println("You clicked me!");
- label.setText("Hello " + textfield.getText());
- }
- }
- <BorderPane fx:controller="application.PlayController" xmlns:fx="http://javafx.com/fxml"
- prefHeight="200" prefWidth="320" >
- <top>
- <Text text="java-Buddy"/>
- </top>
- <left>
- <Label text="Who are you?"/>
- </left>
- <center>
- <TextField id="textfield" fx:id="textfield"/>
- </center>
- <right>
- <Button id="button" text="Click Me!"
- onAction="#handleButtonAction" fx:id="button"/>
- </right>
- <bottom>
- <Label id="label" fx:id="label"/>
- </bottom>
- </BorderPane>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement