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 trialjames white
78,399 PointsAdd an event handler for playButton
Here's my code:
playButton.setOnAction(new EventHandler<ActionEvent>(){
@Override
public void handle(ActionEvent event) {
System.out.println("Playing!");
}
});
I think I may be close but still getting "Bummer!" error on the Event Handler line...
The code is similar to the code on these pages:
https://docs.oracle.com/javafx/2/get_started/hello_world.htm
http://www.programcreek.com/java-api-examples/index.php?api=javafx.scene.control.Button
Any suggestions?
3 Answers
Craig Dennis
Treehouse TeacherHi james white !
Try using a lambda like I do in the video leading up to this code challenge: Adding Interactivity at 3:40.
Let me know if that helps!
james white
78,399 PointsHi Craig, Thanks! I thought it was too simple to be a one-liner like:
playButton.setOnAction(evt -> System.out.println("Playing!"));
Hope this JavaFX course is only the first of a series.
Maybe the next one can be a game with some OpenGL involved.
Craig Dennis
Treehouse TeacherHey James, great idea! Want me to add that to the Java content roadmap Trello board?
james white
78,399 PointsYes please!
I bookmarked that Trello board (which I hadn't known existed) as a sort of "pre-Roadmap" page.
I see there is a "Swing Data" course planned (which is interesting to see what they do with
dashboard-ing graphics-created-on-the-fly for the data),
but having worked with Swing and SWT over the years,
I think JavaFX has more momentum going forward (at least with me).
I've done some work to integrate/overlay JavaFX with JME (JMonkey 3) and hopefully that
kind of thing pops up in a Treehouse course at some point.
Overall I know there's more Java content coming, it's just so agonizingly slow
watching the roadmap (and content creation) pipeline,
but keep up the good work. james