Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to set background color in a scene?

DalePJul 31 2013 — edited Jul 31 2013

I'm new to JavaFX and just started my first FX program.  I created an FX project in NetBeans 7.3 and the project runs properly.   All of the samples in the JavaFX samples download run as well.  But when I try to do something as simple as setting the background color on my first scene to black, I can't get it to work.  I find examples and documentation that tell me that what I am doing should work but it does not. 

        Scene scene = new Scene(root, 300, 250, Color.BLACK);

        scene.setFill(Color.BLACK);

        primaryStage.initStyle(StageStyle.UNDECORATED);

        primaryStage.setTitle("Hello World!");

        primaryStage.setScene(scene);

The two bold lines are marked as errors.  Unfortunately, I can't find a way to copy the error popup text in the IDE so I'll summarize.  Both lines are giving errors that say that I gave a Color but a Paint was expected.

Is there something I am missing? Can it be this hard to set a background color in JavaFX?

Thanks.

This post has been answered by shakir.gusaroff on Jul 31 2013
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 28 2013
Added on Jul 31 2013
2 comments
1,044 views