Welcome!

Linux Authors: Reuven Cohen, Michael Sheehan, Lavenya Dilip, Ian Thain, Bruce Armstrong

Related Topics: Java

Java: Article

A Compiled JavaFX Script Example: Spinning Wheel Got to Go 'Round

This application in JavaFX Script demonstrates several compiled JavaFX Script features

Here's a sample program that uses the WinnerWheelJFX component:

/*
*  WinnerWheelExample.fx - A JavaFX example
* of using a custom component
*
*  Developed 2008 by James L. Weaver
* (jim.weaver at lat-inc.com)
*/

import javafx.ui.*;
import java.lang.System;

Frame {
  var winnerWheel =
    WinnerWheelJFX {
      names: [
        "Aaaaaaaa Aaaaaa",
        "Bbbbbbbb Bbbbbb",
        "Cccccccc Cccccc",
        "Dddddddd Dddddd",
        "Eeeeeeee Eeeeee",
        "Ffffffff Ffffff",
        "Gggggggg Gggggg",
        "Hhhhhhhh Hhhhhh",
        "Iiiiiiii Iiiiii",
        "Jjjjjjjj Jjjjjj",
        "Kkkkkkkk Kkkkkk",
        "Llllllll Llllll",
        "Mmmmmmmm Mmmmmmmmmmm"
      ]
    }
  title: "Winner Wheel JFX"
  height: 750
  width: 800
  resizable: false
  visible: true
  content:
    Canvas {
      background: Color.WHITE
      content: winnerWheel
    }
  onClose:
    function():Void {
      System.exit(0);
    }
}

Compiling and Running this Example

Use the normal commands to compile and run this example, but since there are two source files, to compile them you'll want to use a wildcard as shown below:

javafxc *.fx

To run the example, use the following command:

javafx WinnerWheelExample

Give it a whirl!

JavaFX Script Boot Camp Announcement


As a heads-up, I will be offering a JavaFX Script 2.5 day "boot camp" on Wednesday, April 9 through Friday, April 11, 2008 (ending at noon) in Indianapolis, Indiana.  This course is designed to get you quickly up to speed in JavaFX Script application development.  A primary reference for this course is my JavaFX Script book, but the course has its own syllabus which includes material covered in the book as well as up to the minute developments in compiled JavaFX Script. Registration will open soon, and for this pilot class I am accepting 12 students. 

The cost of this pilot class will be 900 USD per student. Additional students from the same organization will be 600 USD.  You'll need to bring your laptop computer with the latest versions of the JavaFX Script downloads (which I'll specify in more detail as the class date approaches).  The prerequisite for the class will be the completion of a JavaFX Script programming assignment that I'll post soon to this weblog.  I'm looking forward to teaching this class and hope that you can attend!

More details to follow.

More Stories By James L. Weaver

James L. (Jim) Weaver is founder and president of jMentor, formed in 2000 to provide Java programming-related training to companies and individuals. He has served as a system architect and developer for over 25 years, specializing in leading-edge software development. His specialties include Java, object-oriented, and web-based technologies. He has authored books on the Java programming language, including most recently JavaFX Script, published by Apress.

Comments (2) View Comments

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.


Most Recent Comments
Tattoo Designs 07/24/08 07:03:37 PM EDT

Interesting little idea. I'd like to see it made into a more useful example, or used for a more practical purpose.

MICR Toner 06/23/08 01:51:54 AM EDT

So, this is sort of like a wheel of fortune interface for random selection of a bunch of names we can enter? I'll try it out. It could come in handy one day.