Skip to main content

Using Scene Buulder with JavaFX

Please note these forums are being decommissioned and use the new and improved forums at
1 reply [Last post]
Joined: 2014-07-13

Hi! After reading Scott Hommel's "Working with Canvas", I built a simple application that just contained a Canvas, fx:id canvas. The controller file linked this object using the code:- @FXML; private Canvas canvas;

But in the main application file the word canvas is underlined in red. How do I fix this?


Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2014-07-18

You cannot give a variable access modifiers inside of a function (example: your main function). Either get rid of "private" or declare the variable with the private access modifier outside of your main class.

If you are using eclipse and you get a red underline, hover the mouse over the variable with the red underline and leave it there for a second. It will show you what the error is and suggestions on how to fix it.