Question

Need Java Code for this Algorithm Workbench question: Suppose we have a stylesheet named styles.css, and...

Need Java Code for this Algorithm Workbench question:

Suppose we have a stylesheet named styles.css, and in our Java code the scene variable references the Scene object. Write a statement to add the stylesheet to the scene.

Ratings will be given, and comments.

Thanks

0 0
Add a comment Improve this question Transcribed image text
Answer #1
    URL url = this.getClass().getResource("styles.css");//adding external css to scene variable
    //URL is scene object and url is scene variable
    if (url == null) {
        System.out.println("Resource not found. Aborting.");
        System.exit(-1);
    }
    String css = url.toExternalForm();
     
    scene.getStylesheets().add(css);
Add a comment
Know the answer?
Add Answer to:
Need Java Code for this Algorithm Workbench question: Suppose we have a stylesheet named styles.css, and...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT