Friday 27 March 2009

Getting JFXtras to run on a Mac

Many people have encountered problems getting JFXtras to run on a Mac and a number of solutions have been proferred.

This simple solution worked for me:

1 - Close Netbeans
2 - Open a terminal window
3 - cd /System/Library/Frameworks/JavaVM.framework/Versions
4 - rm -f CurrentJDK (this is just a symlink to version you are using)
5 - ln -s 1.6 CurrentJDK
6 - close terminal window
7 - start Netbeans

Just to test it, I threw together the following code (copied and paste from various resources, so nothing original here)


/*
* Main.fx
*
* Created on Mar 27, 2009, 7:34:38 AM
*/

package test;

import javafx.ext.swing.SwingButton;
import javafx.lang.FX;
import javafx.scene.layout.HBox;
import javafx.scene.Scene;
import javafx.scene.text.Font;
import javafx.scene.text.Text;
import javafx.stage.Stage;

/**
* @author johndunning
*/
var stage:Stage;

stage = Stage {
title: "Application title"
width: 250
height: 80
scene: Scene {
content: [ Text {
font : Font {
size : 16
}
x: 10, y: 30
content: "Application content"
},
HBox {
content: [

SwingButton {
text:"Click Me"
action:function()
{
var help:Help = Help{}
help.showHelp(stage);
}
},
SwingButton {
text:"Exit"
action:function()
{
FX.exit();
}

}
]
}


];
}
}



package test;

import javafx.ext.swing.SwingButton;
import javafx.ext.swing.SwingLabel;
import javafx.scene.Scene;
import javafx.stage.Stage;
import org.jfxtras.scene.layout.Cell;
import org.jfxtras.scene.layout.Grid;
import org.jfxtras.scene.layout.GridConstraints;
import org.jfxtras.scene.layout.Row;
import org.jfxtras.stage.JFXDialog;

package class Help
{
package function showHelp (owner: Stage): Void
{
def helpText = ""
"Welcome to Text Search!

"
"Enter the search text in the text field.
"
"Click Search to initiate the search.
"
"Click Stop to interrupt a search.
"
"Click Help to display this help.
"
"
"
"The paths of all files that contain
"
"the search text appear in the list."
"";

var dialogRef: JFXDialog;
dialogRef = JFXDialog
{
title: "Text Search Help"

owner: owner
modal: true
packed: true
resizable: false

scene: Scene
{
content: Grid
{
border: 15

rows:
[
Row
{
cells: SwingLabel
{
text: helpText
}
}
Row
{
cells: Cell
{
content: SwingButton
{
action: function (): Void
{
dialogRef.close ()
}

text: "OK"
}

horizontalAlignment: GridConstraints.CENTER
}
}
]

vgap: 10
}
}
}
}
}