I just want to wish you a Happy New Year, and to show you an example of date formatting in compiled JavaFX Script. First, here are the screenshots of a few invocations of the program, each one taken after having changed to a different locale on my computer. Of course, your computer is probably already set to your desired locale, so when you run this program, you should see the word "Happy", followed by the day of the week in your language, followed by the date in your language (of the first day of 2008).
Here's the program, followed by a brief explanation of its formatting aspects:
/*
* HappyNewYearFormatting.fx - Example of using formatting
* in compiled JavaFX Script
*
* Developed 2007 by James L. Weaver (jim.weaver at lat-inc.com)
*/
import javafx.ui.*;
import javafx.ui.canvas.*;
import java.lang.System;
import java.text.DateFormat;
import java.util.GregorianCalendar;
Frame {
title: "Happy New Year!"
width: 500
height: 100
background: Color.WHITE
visible: true
content:
Canvas {
var cal = new GregorianCalendar(2008, 0, 1)
var df = DateFormat.getDateInstance(DateFormat.LONG)
content:
Text {
font:
Font {
face: FontFace.SANSSERIF
style: FontStyle.PLAIN
size: 24
}
stroke: Color.RED
fill: Color.RED
x: 15
y: 25
content: bind "Happy {%tA cal}, {df.format(cal.getTime())}"
}
}
}
Formatting in Compiled JavaFX Script
You can control how numbers and dates are converted to character strings by providing an additional formatting prefix in a String expression. This prefix follows the specification of the Java Formatter class. In the example above, I'm using the %tA formatting prefix to convert the date to the day of the week in the default locale. I'm also using the capabilities of the Java DateFormat class to show the month, day and year in the language and order of the default locale.
Please have a happy, healthy, and prosperous 2008,
Jim Weaver
JavaFX Script: Dynamic Java Scripting for Rich Internet/Client-side Applications
Immediate eBook (PDF) download available at the book's Apress site
Well, I don’t know if this rule holds true across the board or not, but it certainly seems to be the case for Bowman & Landes Free Range Turkey Farm in New Carlisle, OH. Recently I drove through two hours of snowy Ohio scenery to meet up with the folks at Bowman & Landes, who gave me the grand tour of their turkey farm.
Posted by: homes for sale costa rica | April 24, 2010 at 04:28 PM
Rick,
The JavaFX compiler creates JVM bytecode in .class files, and the original FX files are not necessary for execution. Jar files are not created as a part of the javafxc process that I've referenced on this list.
You may be talking about interpreted JavaFX Script, which is just a working prototype for the compiled version, and should not be necessary too much longer.
Posted by: Jim Weaver | February 07, 2008 at 11:48 AM
Hello,
I was curious. I've noticed that "compiling" JavaFX script simply puts .fx files into a Java archived file (JAR).
However, anyone can go into that .jar file and see the code I wrote for the application, which may include database URL, login credentials, etc.
Aside from creating separate Java classes to grab this sensitive information, is there any way to "literally" create a jar file with some form of compiled (binary) representation of your JavaFX script files?
Any feedback would be greatly appreciated, either here or at my e-mail address.
Posted by: Rick | February 07, 2008 at 11:13 AM