Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering JavaFX 10

You're reading from   Mastering JavaFX 10 Build advanced and visually stunning Java applications

Arrow left icon
Product type Paperback
Published in May 2018
Publisher Packt
ISBN-13 9781788293822
Length 268 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Sergey Grinev Sergey Grinev
Author Profile Icon Sergey Grinev
Sergey Grinev
Arrow right icon
View More author details
Toc

Table of Contents (15) Chapters Close

Preface 1. Stages, Scenes, and Layout 2. Building Blocks – Shapes, Text, and Controls FREE CHAPTER 3. Connecting Pieces – Binding 4. FXML 5. Animation 6. Styling Applications with CSS 7. Building a Dynamic UI 8. Effects 9. Media and WebView 10. Advanced Controls and Charts 11. Packaging with Java9 Jigsaw 12. 3D at a Glance 13. What's Next? 14. Other Books You May Enjoy

Clock demo

Let's apply some of the stuff we learned in this Chapter to the Clock demo we started in the previous chapter.

The digital clock is not as fun as an analog one, so let's add hands to it.

We need three hands—hours, minutes, and seconds. We'll use a simple line for the seconds hand and slightly more complex path shapes for the hour and minute ones. For example, here is the path for the minute hand:

Path minuteHand = new Path(
new MoveTo(0, 0),
new LineTo(15, -5),
new LineTo(100,0),
new LineTo(15,5),
new ClosePath());
minuteHand.setFill(Color.DARKGRAY);

This code gives us not the prettiest but a conveniently simple hand. We'll work on making it nicer in following chapters:

To show time, the hand has to rotate. We'll use the Rotate transformation. We need to rotate...

You have been reading a chapter from
Mastering JavaFX 10
Published in: May 2018
Publisher: Packt
ISBN-13: 9781788293822
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime