DZone
Java Zone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
  • Refcardz
  • Trend Reports
  • Webinars
  • Zones
  • |
    • Agile
    • AI
    • Big Data
    • Cloud
    • Database
    • DevOps
    • Integration
    • IoT
    • Java
    • Microservices
    • Open Source
    • Performance
    • Security
    • Web Dev
DZone > Java Zone > Playing with the JavaFX SDK as it's Being Built

Playing with the JavaFX SDK as it's Being Built

James Weaver user avatar by
James Weaver
·
Jun. 09, 08 · Java Zone · Interview
Like (0)
Save
Tweet
9.08K Views

Join the DZone community and get the full member experience.

Join For Free

as i mentioned in the jfx and the way forward after javaone 2008 post, sun announced at javaone that a preview release of the javafx sdk is scheduled to be available in july 2008.  as a pleasant surprise over memorial day weekend, sun opened up the development of this preview release sdk.  this development activity is occurring as a part of the openjfx compiler project, so follow the instructions that i gave you in the obtaining the openjfx script compiler just got easier post and join the fun!  you'll be playing with the javafx sdk as it is being built, so expect changes.  it would also be great if you'd provide input to the process, and help test the sdk as it's being developed.

write your first javafx program that uses the new javafx.gui classes

take a look at the javafx script api documentation and you'll notice that there are two sets of ui-related packages.  the javafx.ui packages contains the older, prototype ui classes, and the javafx.gui packages contain the ui classes that will be in the javafx sdk.  the javafx code below uses these newer ui classes, and i'll show you how to compile and run this code in a bit.  when the application first starts up, an empty window appears with two buttons:

blank

when you click the hello button, the message "you say hello..." from the popular "hello, goodbye" beatles song displays approximately in the center of the window:

hello

when you click the goodbye button, the message "and i say goodbye" appears in place of the former message:

goodbye

here's the javafx code that generated this user interface and functionality:

/*
* hellogoodbye.fx -
* a "hello world" style program that demonstrates
* declaratively expressing a user interface.
*/
package beatles;
import javafx.gui.*;

frame {
var phrase:string
title: "hello, goodbye"
height: 300
width: 400
visible: true
content:
borderpanel {
center:
canvas {
content:
text {
x: 50
y: 125
content: bind phrase
font:
font {
size: 36
}
}
}
bottom:
flowpanel {
content: [
button {
text: "hello"
action:
function():void {
// the button was clicked
phrase = "you say hello...";
}
},
button {
text: "goodbye"
action:
function():void {
phrase = "and i say goodbye";
}
}
]
}
}
}

compiling and running the program

to compile this program, enter the following into the command line:

javafxc -d . hellogoodbye.fx

as in java, the -d option causes the class files to be put into a directory corresponding to the package statement subordinate to the specified directory.  to run the program, use the following command:

javafx beatles.hellogoodbye

now that you've got access to the javafx sdk as it's being built, get involved by writing javafx programs that exercise its functionality, and subscribe to one or more of the following mailing lists from this page .

users@openjfx-compiler.dev.java.net

gui@openjfx-compiler.dev.java.net

dev@openjfx-compiler.dev.java.net

javafxpert bootcamp in oslo, norway, on june 18-20, 2008

if you happen to be in the vicinity of oslo, norway later this month, please come to the free javafx script seminar sponsored by bouvet on june 18, 2008.  i'll be teaching the seminar, followed by a two day javafxpert bootcamp .  contact bouvet for information on registering for the bootcamp.

have fun, and please post a comment if you have any questions!
jim weaver
javafx script: dynamic java scripting for rich internet/client-side applications
immediate ebook (pdf) download available at the book's apress site

JavaFX Software development kit IT

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • Use Lambda Function URL To Write a Serverless App Backed by DynamoDB
  • Querying Kafka Topics Using Presto
  • A Simple Guide to Heaps, Stacks, References, and Values in JavaScript
  • How Database B-Tree Indexing Works

Comments

Java Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • MVB Program
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends:

DZone.com is powered by 

AnswerHub logo