Archives for the ‘javafx’ Category

JavaFX experiment

I was having a lot of problems getting the simplest test case below to run without throwing an odd exception:

import javafx.stage.Stage;
import javafx.scene.Scene;
import javafx.scene.layout.*;
import javafx.ext.swing.SwingTextField;
import javafx.ext.swing.SwingButton;

Stage {
title : "MyApp"
scene: Scene {
width: 200
height: [...]

JavaFX Custom Cursors

Setting custom cursors with JavaFx is relatively straightforward, but for one little catch. Your image has to be 32×32. If you want a 16×16 icon, simply leave the rest of the image transparent.

import java.awt.Toolkit;
import javafx.scene.Cursor;
import javafx.scene.image.Image;

public class ColorChooser extends Cursor
{
public override function impl_getAWTCursor(): java.awt.Cursor {

[...]

JavaFX Introspection

Just sharing some code snippets for deserialization of JavaFX objects.

function getValueType(obj:Object,name:String):String
{
var context:FXLocal.Context=FXLocal.getContext();
var objectValue:FXLocal.ObjectValue = new FXLocal.ObjectValue(obj,context);
var cls:FXClassType = objectValue.getClassType();
var varType:FXType = cls.getVariable(name).getType();
println("{name} {varType}");
if (varType instanceof FXSequenceType)
{
[...]

JavaFX binding in sequences

I had a Group of circles, i.e.
var circles:Circle[];
var group:Group = Group { content: [circles] };
strangely, I couldn’t get newly inserted circles to render.
It turns out that you have to bind group.content to ensure that changes in circles are reflected in group.content.
Here’s a test routine.

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import javafx.stage.*;

var lines = for (i in [1..10])
[...]

JavaFX redux

Having spent a few weeks experimenting with JavaFX, and creating several examples, here is an assessment of whether JavaFX succeeds in it’s objective of being a graphics DSL. Bear in mind that I am evaluating it in terms of it’s ease in being a graphics DSL – if it makes my life easier, it succeeds. [...]

JavaFX TextAlignment Gotcha

Here is a minimal test case illustrating how exasperating the default JavaFX Text node can be, especially when aligning text.
You’d be surprised to note that both pieces of text below are aligned using TextAlignment.CENTER.

import javafx.scene.text.*;
import javafx.scene.layout.*;

VBox
{
translateY:10
content:
[
Text {
[...]

JavaFX Experiments – Order of Declaration Matters

Given the following piece of JavaFX Script

import javafx.scene.CustomNode;
import javafx.scene.Group;
import javafx.scene.Node;
import javafx.scene.shape.Rectangle;
import javafx.scene.paint.Color;
import java.lang.Math.sqrt;

class C extends CustomNode
{
// Test #1: Commented out
//var node: Group = Group {};

protected override function create():Node
{
return node;
[...]

JavaFX Fidelity

JavaFX gets to start on a clean slate, without burdens of compatibility with browsers. However, how well does it paint itself?
How are – say – Rectangles defined?
Is the startX based on center lines? or is it from the origin?
What about borders? Are borders painted to the bottom right of the origin?
How [...]

JavaFX 1.0 considered

JavaFX 1.0 is finally out of the gate. There are probably many Java engineers and architects who are trying to figure out this technology and see how it could apply to their existing projects. Here is my assessment. Note this applies to JavaFX 1.0.
JavaFX 1.0 is not ready as a Flash replacement in public-facing projects
While [...]

Has the JVM design been holding back Java?

[Note: I've reposted this (with minor edits) as my original post got accidentally deleted. Thanks to Google cache]
Why is it? Why is it that Java applets -despite having the first mover advantage – achieved little traction. While Flash – a tool which targets graphic designers originally – continue to gain mindshare, and is now a [...]

Has the JVM design been holding back Java?

Update:Looks like the post has been linked from DZone. Tell me what you think? What kind of projects would you choose Java applets over Flash or AJAX?

After all these years, Java’s applet has not seen much adoption, while Flash continue to gain mindshare. Applets suffer from slow start up times, crashing browsers, heavy resource usage. [...]

Browsers will Rule Mobile Devices

Five years ago, when prototyping some apps for PDAs, I’d never consider HTML + javascript. This is because there are enough form factor issues as well as browser incompatibilities to keep one awake all night.
Things have changed.
WebKit seems to have gained ground in the mobile space, giving compatibility a much needed shot in the [...]

A concrete proposal for inlining JavaFX

Jan Erik calls me the “high IQ” type. Unfortunately, I think he means “impractical” and “living in an invory tower”.
The idea of a inlining JavaFX script is actually a smaller and incremental goal. It is practical and is achievable. It will allow people who don’t have the JavaFX SDK to experiment with the technology, within [...]

JavaFX and Disembodied Reality

Jan Erik opined insightfully about JavaFX’s prospect:
Java.net is disconnected with reality. For every guy who knows Swing/Java there are a 1000 guys who know HTML/DOM/CSS/Javascript. Silverlight is only marginally important because Microsoft controls 90 percent of the desktop marked and is the company behind C#.
JavaFX will ride the JRE in the same way AIR is [...]

JavaFX Coverflow Part 2

Continuing with our previous example, we now create a CustomNode Coverflows, which contain 11 covers.
A new function called positiveOrZero is introduced so that the tilt angle can be negative.
A fill attribute is introduced to the Cover class and it is bound to the Rectangle.

/**
* Coverflow.fx
**/
package coverflow;

import javafx.application.*;
import javafx.animation.*;
import javafx.input.*;
import javafx.scene.geometry.*;
import javafx.scene.*;
import javafx.scene.paint.*;
import [...]

JavaFX and Unicode source files

The JavaFX compiler supports unicode source files, just as Java compiler does. To use them you need to

make sure the source does not include the three-byte byte-order-mark
call javafxc with the -encoding parameter

javafxc -encoding UTF-8 Chinese.fx
javafx Chinese

And now for the example

import javafx.application.*;
import javafx.scene.Font;
import javafx.scene.text.Text;
import javafx.scene.paint.Color;

Frame {
title: "JavaFX Unicode Example"
width: 400 height: 300
stage: [...]

JavaFX Coverflow Part 1

Warning: Apple Inc apparently has a patent on this. I’m merely doing this for performance comparison purposes and for self-education only.
It’s been about 2 weeks since my first JavaFX session. My initial distaste for the YAML syntax is largely gone. I have avoided using Netbeans, as vim is sufficient. The absence of closing tags in [...]

Why JavaFX should be inlineable with HTML

I was disappointed when I found out JavaFX interpreter is not shipping in the final Java runtime. Shipping the interpreter is key to inlining script with HTML, and will accelerate adoption of this shiny cross-browser platform.

There are tens of millions of web developers who have already been trained to edit text in a file and [...]

Chaining JavaFX effects

Unfortunately, it appears that the only way to chain JavaFX effects together is by using a Group control. (There is a Effect(input1, input2) constructor, but I can’t seem to access it from JavaFX Script, while the Blend effect doesn’t chain effects, but instead applies them in parallel).
To achieve a Coverflow-like look, we apply a reflection [...]

August 18, 2008 Ask the (JavaFX) Experts

me: What is the long term future of javafx.ext.swing.* classes in JavaFX’s
technological roadmap? Are new Node-based ui classes in-the-works to supercede this?
Joshua Marinacci: We plan to keep the swing classes but they will only be in the desktop profile. New gui classes based on nodes are in the works. These new gui components will be [...]