Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialjinhwa yoo
10,042 PointsWhat 's wrong??
java fx application
package com.example;
import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.scene.control.Button;
import javafx.stage.Stage;
public class Home extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Group root = new Group();
Button playButton = new Button();
setOnAction(evt -> system.out.println("Playing"));
root.getChildren().add(playButton);
primaryStage.setTitle("Boombox");
primaryStage.setScene(new Scene(root, 300, 275));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
1 Answer
nihouse
7,160 PointssetOnAction is a method of the Button-Class or in this case of your playButton-Object created above. So would need to do:
``` playButton.setOnAction(evt -> System.out.println("Playing"));