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 trialada
Courses Plus Student 5,378 PointsWhy " Label label = new Label("Name:"); " doesn't work?
Hello,
I was wondering why when I type the line of code to create a new Label in my JavaFx project it doesn't work and gives the error message of " Label() cannot be applied to '(java.lang.String)' "
Label label = new Label("Name:");
After some quick trials, I figured that this works instead,
javafx.scene.control.Label label = new javafx.scene.control.Label("Name:");
As a newbie, I'm clueless why? Is there something wrong with my Intellij' settings?
1 Answer
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,175 PointsCheck import
statement.
Up top in file should be
import javafx.scene.control.Label;
You've probably imported wrong label. The one that does not have constructor with String