Reflection on JavaFx

On Java, when we want to invoke a method from an existing instance of an object, we can simply call:
public Object invoke(Object obj,
                     Object... args)
              throws IllegalAccessException,
                     IllegalArgumentException,
                     InvocationTargetExceptionPassing the object reference in obj.
But I can't do the same in JavaFx.
In JavaFx we need FXFunctionMember and FXObjectValue to invoke a method.
I could obtain FXFunctionMember using getFunction(...) on ClassType class.
Most exemples that I saw was creating an instance and then using it. But I don't know how I can obtain a FXObjectValue object to an instance that already being created.
I read a lot of the JavaFx API reflexive package and yet I haven't found anything.

var foocls = FXContext.getInstance().findClass("Foo");
var fun : FXFunctionMember = foocls.getFunction("bar");
var obj = Foo{};
var objval = FXLocal.getContext().mirrorOf(obj);
fun.invoke(objval);

Similar Messages

  • Bug or feature: BorderPane ignores reflection in sizing

    Just started to explore fx (read: complete newbie here :-), so grabbing code examples and came across one by Walter (below is a minimal extract of the fx app):
    http://weblogs.java.net/blog/ixmal/archive/2011/06/02/using-javafx-20-inside-swing-applications#comment-815938
    It's a simple Label with reflection. Problem is that the reflection is not completely visible if added to the center of a BorderPane (nor a StackPane), looks somehow translated in y direction. All okay when added to top or with a VBox/HBox/FlowPane.
    Ideas? Or in other words: what I'm missing or doing wrong ;-)
    Thanks
    Jeanette
    public class LayoutLabel extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            stage.setTitle("Test JFX");
            stage.setScene(createScene());
            stage.setVisible(true);
        private Scene createScene() {
            Label label = new Label("Hello world!");
            label.setFont(new Font(24));
            label.setEffect(new Reflection());
            BorderPane pane = new BorderPane();
            pane.setCenter(label);
    //        pane.setTop(label);
    //        pane.setBottom(label);
    //        Pane pane = new StackPane();
    //        Pane pane = new FlowPane();
    //        Pane pane = new HBox();
    //        pane.getChildren().add(label);
            Scene scene = new Scene(pane);
            return scene;
        public static void main(String[] args) {
            Application.launch(args);
    }

    Hi,
    I did not quiet understand what you mean. It looks completely visible for me.
    You did not set scene width and height so maybe that is reason why it was not visible.
    This code works for me:
    package playground;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.effect.Reflection;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.text.Font;
    import javafx.stage.Stage;
    public class LayoutLabel extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            stage.setTitle("Test JFX");
            stage.setScene(createScene());
            stage.setVisible(true);
        private Scene createScene() {
            Label label = new Label("Hello world!");
            label.setFont(new Font(24));
            Reflection reflection = new Reflection();
            reflection.setFraction(1.0);
            reflection.setBottomOpacity(1.0);
            reflection.setTopOffset(0.0);
            label.setEffect(reflection);
    //        Group pane = new Group();
            BorderPane pane = new BorderPane();
            pane.setCenter(label);
    //        pane.setTop(label);
    //        pane.setBottom(label);
    //        Pane pane = new StackPane();
    //        Pane pane = new FlowPane();
    //        Pane pane = new HBox();
    //        pane.getChildren().add(label);
            Scene scene = new Scene(pane, 200,200); // changes to 200 200 maybe that is reason why it does not show
            return scene;
        public static void main(String[] args) {
            Application.launch(args);
    }

  • Embedding JavaFX v1.2 Scene's in Swing

    Before I start... SUN DOES NOT SUPPORT THIS AND IT IS LIKELY TO CHANGE... hopefully we get official support in a future release, please :)
    +"Note: We also recognize the need for the inverse (embedding a JavaFX scene into a Swing app), however that is not supported with 1.2 as it requires a more formal mechanism for manipulating JavaFX objects from Java code. The structure of these JavaFX objects is a moving target (for some very good reasons) and we're not ready to lock that down (yet). However,as with most software, this can be hacked (see Rich & Jasper's hack on Josh's blog) but know that you are laying compatibility down on the tracks if you go there. "+ Source: http://weblogs.java.net/blog/aim/archive/2009/06/insiders_guide.html
    But if you really really want this now read on.
    After a lengthy investigation and some help from others (including the jfxtra's project) here is how to Embed a JavaFX scene in your Swing application:
    First, start your java application with javafx and not java! This will fix any potential class path issues and really does solve a lot of issues you will have 'patching' the JVM with JavaFX (if that is even possible). JavaFX will happily run a Java project (with the JVM) even if there is not one JavaFX class in your project.
    Next, you need to create a Java Interface for your JavaFX object to implement:
    package mix.javastuff;
    * This is a Java Interface that your JavaFX class should implement.
    * This will define how Java will interact with your JavaFX class.
    * @author ahhughes
    public interface TextDisplay {
        public void setText(String text);
    }Next, you need to create your JavaFX object... it must extend Scene and you are to provide any interaction with Java you will need to implement a java interface:
    package mix.javafxstuff;
    import mix.javastuff.TextDisplay;
    import javafx.scene.Scene;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    import javafx.scene.effect.Reflection;
    import javafx.scene.text.TextOrigin;
    * Here is a very simple scene, that implements a java interface
    * That allows Java (or JavaFX) to setText on the Scene's content.
    public class TextDisplayJavaFXScene extends Scene , TextDisplay {
        override public function setText(text:String):Void{
            content = Text {
                    font : Font {size: 44}
                    x: 0, y: 0
                    textOrigin: TextOrigin.TOP
                    content: text
                    effect: Reflection {}
    }Finally, you need to use some reflection and some under the hood magic to get your JavaFX object and wrap in in a SwingScene (which just so happens to extend JComponent).
    package mix.javastuff;
    import com.sun.javafx.tk.swing.SwingScene;
    import java.awt.FlowLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;
    import javafx.reflect.FXClassType;
    import javafx.reflect.FXContext;
    import javafx.reflect.FXFunctionMember;
    import javafx.reflect.FXLocal;
    import javafx.reflect.FXLocal.ObjectValue;
    import javafx.scene.Scene;
    import javax.swing.JButton;
    import javax.swing.JComponent;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JTextField;
    * Example of how to inject JavaFX into your Swing app.
    public class Main {
        private static final FXLocal.Context context = FXLocal.getContext();
        private static TextDisplay textDisplayJavaFXScene;// javafx scene & java interface
        public static void main(String[] args) {
            //Get the JavaFX Object, that has 'extends Scene, SomeJavaInterface'
         FXClassType instanceType = context.findClass("mix.javafxstuff.TextDisplayJavaFXScene");
         ObjectValue objectInstance = (ObjectValue) instanceType.newInstance();
         textDisplayJavaFXScene = (TextDisplay) objectInstance.asObject();
            //Wrap this in a SwingScene using refection
            JComponent textDisplayJavaFXSwingScene = sceneInstanceToJComponent((Scene)textDisplayJavaFXScene);
            //Now let's show the JComponent+JavaFXScene in a simple Swing App.
            createSimpleSwingApp(textDisplayJavaFXSwingScene);
         * This method wraps the Scene with a JComponent. This is what you can add
         * to your Swing application.
         * @param scene the JavaFX object that extends javafx.scene.Scene.
         * @return the javafx.scene.Scene wrapped by a JComponent.
         public static JComponent sceneInstanceToJComponent(Scene scene) {
             FXClassType sceneType = FXContext.getInstance().findClass("javafx.scene.Scene");
             ObjectValue obj = FXLocal.getContext().mirrorOf(scene);
             FXFunctionMember getPeer = sceneType.getFunction("impl_getPeer");
             FXLocal.ObjectValue peer = (ObjectValue) getPeer.invoke(obj);
             SwingScene swingScene = (SwingScene)peer.asObject();
             return (JComponent) swingScene.scenePanel;
         * OK, this method is just to show you this in action.... the real stuff
         * you are interested is in the methods above.
         * @param javaFXTextDisplaySwingScene
        private static void createSimpleSwingApp(JComponent javaFXTextDisplaySwingScene){
             JFrame frame = new JFrame();
             frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
             frame.setSize(500,500);
             frame.setAlwaysOnTop(true);
              JPanel panel = new JPanel();
              panel.setLayout(new FlowLayout());
            //create a swing interface to interact with textDisplayJavaFXScene.setText()
            final JTextField textInputField = new JTextField("Set THIS Text!");
              panel.add(textInputField);
              JButton button = new JButton("Send to JavaFX!");
              panel.add(button);
              button.addActionListener(new ActionListener() {
                   @Override
                   public void actionPerformed(ActionEvent e) {
                        textDisplayJavaFXScene.setText(textInputField.getText());
            //add the JavaFX SwingScene to the Swing's JPanel
             panel.add(javaFXTextDisplaySwingScene);
            //display the swing app
             frame.add(panel);
             frame.setVisible(true);
    }That's it!

    morningstar wrote:
    You can refer to this article for how to embeded javaFX scene into SWING:
    [JavaFX Scene embedded in SWING Window|http://www.javafxgame.com/javafx-scene-swing-java/]
    [http://www.javafxgame.com/javafx-scene-swing-java/|http://www.javafxgame.com/javafx-scene-swing-java/]
    Hi morningstar, this article is good and it too helped me out A LOT! It shows how to embed a JavaFX scene in swing but doesn't show you how to interact with JavaFX objects FROM your Java/Swing code. Wrapping the JavaFX node in a SwingScene doesn't offer a way for the Java/Swing code to interact with the underlying JavaFX objects.
    How can you set the text in the JavaFX Text node from the Java/Swing code in the linked article? You can't, all you can do is have the JavaFX objects reference BACK to public static fields in your Java code (not the best):
    Java Class:
    public class JavaFXToSwingTest extends JFrame {
        public static JTextField tf = new JTextField("JavaFX for SWING");
        //other code
    JavaFX Class:
        text = JavaFXToSwingTest.tf.getText();  On the other hand, the code in the first post exposes the JavaFX objects through java interfaces as well as wrapping them in a SwingScene. This means that you can do YourJavaFXObject.setText("Blah"); from inside your Java/Swing code, rather handy! :)
    Edited by: AndrewHughes on Jul 27, 2009 12:25 AM

  • ScrollBar visibleAmountProperty JavaFX 2.1.1 and 2.2.0-beta

    Hi,
    I'm new to JavaFX. I tried the JavaFX examples provided by Oracle. In the Ensemble.jar there is an example called "Display Shelf" where several images are loaded and at the bottom you can see a scrollbar.
    I have a question to the setVisibleAmount method of a ScrollBar. If I understood properly, the visibleAmountProperty specifies the size of the scroll bar's thumb. When I start the "Display Shelf" example with only 2 images (see the code below), the thumb of the scrollbar fills the complete scrollbar. My expectation was that the thumb only fills half of the available space. That is the reason why I played with the visibleAmountProperty and found out that scrollBar.setVisibleAmount(0.5) works fine for 2 images. But I don't understand why and how this property works. My understanding was:
    If I load 2 images and setVisibleAmount is set to 1, the size of the thumb should be 1/2 of the scrollbar's size;
    if I load 14 images and setVisibleAmount is set to 1, the size of the thumb should be 1/14 of the scrollbar's size.
    If I set the visibleAmountProperty to 0, I understand that the thumb's size is not adjusted. But I don't want to use 0 because it is too small for my application. The thumb's size should be adjusted depending on the number of loaded images.
    Can you explain me how setVisibleAmount works and to which value it should be set? (Is there a bug?)
    Here is the slightly modified "Display Shelf" example:
    * Copyright (c) 2008, 2012 Oracle and/or its affiliates.
    * All rights reserved. Use is subject to license terms.
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    import javafx.animation.Interpolator;
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.Timeline;
    import javafx.beans.InvalidationListener;
    import javafx.beans.Observable;
    import javafx.beans.property.DoubleProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.collections.ObservableList;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Parent;
    import javafx.scene.control.ScrollBar;
    import javafx.scene.effect.PerspectiveTransform;
    import javafx.scene.effect.ReflectionBuilder;
    import javafx.scene.image.Image;
    import javafx.scene.image.ImageView;
    import javafx.scene.input.KeyCode;
    import javafx.scene.input.KeyEvent;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.Region;
    import javafx.scene.shape.Rectangle;
    import javafx.util.Duration;
    * A display shelf of images using the PerspectiveTransform effect.
    * @see javafx.scene.effect.PerspectiveTransform
    * @see javafx.scene.effect.Reflection
    * @see javafx.scene.control.ScrollBar
    * @see javafx.scene.input.MouseEvent
    * @see javafx.scene.input.KeyEvent
    * @resource animal1.jpg
    * @resource animal2.jpg
    * @resource animal3.jpg
    * @resource animal4.jpg
    * @resource animal5.jpg
    * @resource animal6.jpg
    * @resource animal7.jpg
    * @resource animal8.jpg
    * @resource animal9.jpg
    * @resource animal10.jpg
    * @resource animal11.jpg
    * @resource animal12.jpg
    * @resource animal13.jpg
    * @resource animal14.jpg
    public class DisplayShelfSample extends Application {
        private static final double WIDTH = 450, HEIGHT = 300;
        private void init(Stage primaryStage) {
            Group root = new Group();
            primaryStage.setResizable(false);
            primaryStage.setScene(new Scene(root, 495,300));
            // load images
    //        Image[] images = new Image[14];
    //        for (int i = 0; i < 14; i++) {
    //            images[i] = new Image( DisplayShelfSample.class.getResource("animal"+(i+1)+".jpg").toExternalForm(),false);
    /*start of my modification: load only 2 images instead of 14*/
            Class<DisplayShelfSample> clazz = DisplayShelfSample.class;
            ClassLoader cl = clazz.getClassLoader();
            Image[] images = new Image[2];
            for (int i = 0; i < 2; i++) {
                images[i] = new Image(cl.getResource("smallimage"+(i+1)+".jpg").toExternalForm(),false);
    /*end of my modification*/
            // create display shelf
            DisplayShelf displayShelf = new DisplayShelf(images);
            displayShelf.setPrefSize(WIDTH, HEIGHT);
            root.getChildren().add(displayShelf);
         * A ui control which displays a browsable display shelf of images
        public static class DisplayShelf extends Region {
            private static final Duration DURATION = Duration.millis(500);
            private static final Interpolator INTERPOLATOR = Interpolator.EASE_BOTH;
            private static final double SPACING = 50;
            private static final double LEFT_OFFSET = -110;
            private static final double RIGHT_OFFSET = 110;
            private static final double SCALE_SMALL = 0.7;
            private PerspectiveImage[] items;
            private Group centered = new Group();
            private Group left = new Group();
            private Group center = new Group();
            private Group right = new Group();
            private int centerIndex = 0;
            private Timeline timeline;
            private ScrollBar scrollBar = new ScrollBar();
            private boolean localChange = false;
            private Rectangle clip = new Rectangle();
            public DisplayShelf(Image[] images) {
                // set clip
                setClip(clip);
                // set background gradient using css
                setStyle("-fx-background-color: linear-gradient(to bottom," +
                        " black 60, #141414 60.1%, black 100%);");
                // style scroll bar color
                scrollBar.setStyle("-fx-base: #202020; -fx-background: #202020;");
                // create items
                items = new PerspectiveImage[images.length];
                for (int i=0; i<images.length; i++) {
                    final PerspectiveImage item =
                            items[i] = new PerspectiveImage(images);
    final double index = i;
    item.setOnMouseClicked(new EventHandler<MouseEvent>() {
    public void handle(MouseEvent me) {
    localChange = true;
    scrollBar.setValue(index);
    localChange = false;
    shiftToCenter(item);
    // setup scroll bar
    scrollBar.setMax(items.length-1);
    scrollBar.setVisibleAmount(0.5);
    scrollBar.setUnitIncrement(1);
    scrollBar.setBlockIncrement(1);
    scrollBar.valueProperty().addListener(new InvalidationListener() {
    public void invalidated(Observable ov) {
    if(!localChange)
    shiftToCenter(items[(int)scrollBar.getValue()]);
    // create content
    centered.getChildren().addAll(left, right, center);
    getChildren().addAll(centered,scrollBar);
    // listen for keyboard events
    setFocusTraversable(true);
    setOnKeyPressed(new EventHandler<KeyEvent>() {
    public void handle(KeyEvent ke) {
    if (ke.getCode() == KeyCode.LEFT) {
    shift(1);
    localChange = true;
    scrollBar.setValue(centerIndex);
    localChange = false;
    } else if (ke.getCode() == KeyCode.RIGHT) {
    shift(-1);
    localChange = true;
    scrollBar.setValue(centerIndex);
    localChange = false;
    // update
    update();
    @Override protected void layoutChildren() {
    // update clip to our size
    clip.setWidth(getWidth());
    clip.setHeight(getHeight());
    // keep centered centered
    centered.setLayoutY((getHeight() - PerspectiveImage.HEIGHT) / 2);
    centered.setLayoutX((getWidth() - PerspectiveImage.WIDTH) / 2);
    // position scroll bar at bottom
    scrollBar.setLayoutX(10);
    scrollBar.setLayoutY(getHeight()-25);
    scrollBar.resize(getWidth()-20,15);
    private void update() {
    // move items to new homes in groups
    left.getChildren().clear();
    center.getChildren().clear();
    right.getChildren().clear();
    for (int i = 0; i < centerIndex; i++) {
    left.getChildren().add(items[i]);
    center.getChildren().add(items[centerIndex]);
    for (int i = items.length - 1; i > centerIndex; i--) {
    right.getChildren().add(items[i]);
    // stop old timeline if there is one running
    if (timeline!=null) timeline.stop();
    // create timeline to animate to new positions
    timeline = new Timeline();
    // add keyframes for left items
    final ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
    for (int i = 0; i < left.getChildren().size(); i++) {
    final PerspectiveImage it = items[i];
    double newX = -left.getChildren().size() *
    SPACING + SPACING * i + LEFT_OFFSET;
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(it.translateXProperty(), newX, INTERPOLATOR),
    new KeyValue(it.scaleXProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.scaleYProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.angle, 45.0, INTERPOLATOR)));
    // add keyframe for center item
    final PerspectiveImage centerItem = items[centerIndex];
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(centerItem.translateXProperty(), 0, INTERPOLATOR),
    new KeyValue(centerItem.scaleXProperty(), 1.0, INTERPOLATOR),
    new KeyValue(centerItem.scaleYProperty(), 1.0, INTERPOLATOR),
    new KeyValue(centerItem.angle, 90.0, INTERPOLATOR)));
    // add keyframes for right items
    for (int i = 0; i < right.getChildren().size(); i++) {
    final PerspectiveImage it = items[items.length - i - 1];
    final double newX = right.getChildren().size() *
    SPACING - SPACING * i + RIGHT_OFFSET;
    keyFrames.add(new KeyFrame(DURATION,
    new KeyValue(it.translateXProperty(), newX, INTERPOLATOR),
    new KeyValue(it.scaleXProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.scaleYProperty(), SCALE_SMALL, INTERPOLATOR),
    new KeyValue(it.angle, 135.0, INTERPOLATOR)));
    // play animation
    timeline.play();
    private void shiftToCenter(PerspectiveImage item) {
    for (int i = 0; i < left.getChildren().size(); i++) {
    if (left.getChildren().get(i) == item) {
    int shiftAmount = left.getChildren().size() - i;
    shift(shiftAmount);
    return;
    if (center.getChildren().get(0) == item) {
    return;
    for (int i = 0; i < right.getChildren().size(); i++) {
    if (right.getChildren().get(i) == item) {
    int shiftAmount = -(right.getChildren().size() - i);
    shift(shiftAmount);
    return;
    public void shift(int shiftAmount) {
    if (centerIndex <= 0 && shiftAmount > 0) return;
    if (centerIndex >= items.length - 1 && shiftAmount < 0) return;
    centerIndex -= shiftAmount;
    update();
    * A Node that displays a image with some 2.5D perspective rotation around the Y axis.
    public static class PerspectiveImage extends Parent {
    private static final double REFLECTION_SIZE = 0.25;
    private static final double WIDTH = 200;
    private static final double HEIGHT = WIDTH + (WIDTH*REFLECTION_SIZE);
    private static final double RADIUS_H = WIDTH / 2;
    private static final double BACK = WIDTH / 10;
    private PerspectiveTransform transform = new PerspectiveTransform();
    /** Angle Property */
    private final DoubleProperty angle = new SimpleDoubleProperty(45) {
    @Override protected void invalidated() {
    // when angle changes calculate new transform
    double lx = (RADIUS_H - Math.sin(Math.toRadians(angle.get())) * RADIUS_H - 1);
    double rx = (RADIUS_H + Math.sin(Math.toRadians(angle.get())) * RADIUS_H + 1);
    double uly = (-Math.cos(Math.toRadians(angle.get())) * BACK);
    double ury = -uly;
    transform.setUlx(lx);
    transform.setUly(uly);
    transform.setUrx(rx);
    transform.setUry(ury);
    transform.setLrx(rx);
    transform.setLry(HEIGHT + uly);
    transform.setLlx(lx);
    transform.setLly(HEIGHT + ury);
    public final double getAngle() { return angle.getValue(); }
    public final void setAngle(double value) { angle.setValue(value); }
    public final DoubleProperty angleModel() { return angle; }
    public PerspectiveImage(Image image) {
    ImageView imageView = new ImageView(image);
    imageView.setEffect(ReflectionBuilder.create().fraction(REFLECTION_SIZE).build());
    setEffect(transform);
    getChildren().addAll(imageView);
    public double getSampleWidth() { return 495; }
    public double getSampleHeight() { return 300; }
    @Override public void start(Stage primaryStage) throws Exception {
    init(primaryStage);
    primaryStage.show();
    public static void main(String[] args) { launch(args); }
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  

    Hi Kaylee,
    From my point of view, the Official Oracle example have 2 bugs. First of all use truncate: http://mindprod.com/jgloss/round.html#TRUNCATE to get the value and then the behaviour its not correct. This is the code of the example: shiftToCenter(items[(int)scrollBar.getValue()]); And the results would be (with just 3 images):
    Scrollbar range: 0 - 2
    Images values: 0, 1, 2
    Scrollbar value: 0.0 shiftToCenterValue:0
    Scrollbar value: 0.4 shiftToCenterValue:0
    Scrollbar value: 0.5 shiftToCenterValue:0
    Scrollbar value: 0.9 shiftToCenterValue:0
    Scrollbar value: 1.0 shiftToCenterValue:1
    Scrollbar value: 1.4 shiftToCenterValue:1
    Scrollbar value: 1.5 shiftToCenterValue:1
    Scrollbar value: 1.9 shiftToCenterValue:1
    Scrollbar value: 2.0 shiftToCenterValue:2
    So the ranges are:
    Image 0: 0,0 - 0,999
    Image 1: 1,0-1,999
    Image 2: 2,0
    If we rounded the value:  shiftToCenter(items[(int)(scrollBar.getValue()+0.5)]); (there are different ways to round a value, this is the fastest one)
    Scrollbar value: 0.0 shiftToCenterValue:0
    Scrollbar value: 0.4 shiftToCenterValue:0
    Scrollbar value: 0.5 shiftToCenterValue:1
    Scrollbar value: 0.9 shiftToCenterValue:1
    Scrollbar value: 1.0 shiftToCenterValue:1
    Scrollbar value: 1.4 shiftToCenterValue:1
    Scrollbar value: 1.5 shiftToCenterValue:2
    Scrollbar value: 1.9 shiftToCenterValue:2
    Scrollbar value: 2.0 shiftToCenterValue:2
    So the ranges are:
    Image 0: 0,0 - 0,4999
    Image 1: 0,5-1,4999
    Image 2: 1,5-2,0
    Much better. But there is also another error, and this if the one that will let you show just 2 images. Change the code: scrollBar.setVisibleAmount(0.5); to scrollBar.setVisibleAmount(1); and then it doesn't deppend on the number of images it always let you navigate through the images. With 10 iamges works, and with 2 images too.
    Maybe the JavaFx team could change these two errors on their example.
    Have a nice week.
    Edited by: ciruman on 06.08.2012 00:41
    Edited by: ciruman on 06.08.2012 00:47

  • Bug or feature? - DHCP with static entries gives "wrong" DNS?

    Server 10.4.8 G4 Xserve
    Bonded interface (built-in and PCI, LACP)
    DHCP, DNS and "more" running.
    DHCP static IP entry (?) windows (and mac?) machines get their DNS IP from the server DNS setting from Network config, not from DHCP config ???
    Machines with no static entry get the DNS IP from the DHCP server setting.
    If you use 127.0.0.1 as the nameserver setting in Network config the static clients obviuosly can't lookup names. I had to use the "hostname IP" instead.

    Hi,
    I did not quiet understand what you mean. It looks completely visible for me.
    You did not set scene width and height so maybe that is reason why it was not visible.
    This code works for me:
    package playground;
    import javafx.application.Application;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Label;
    import javafx.scene.effect.Reflection;
    import javafx.scene.layout.BorderPane;
    import javafx.scene.text.Font;
    import javafx.stage.Stage;
    public class LayoutLabel extends Application {
        @Override
        public void start(Stage stage) throws Exception {
            stage.setTitle("Test JFX");
            stage.setScene(createScene());
            stage.setVisible(true);
        private Scene createScene() {
            Label label = new Label("Hello world!");
            label.setFont(new Font(24));
            Reflection reflection = new Reflection();
            reflection.setFraction(1.0);
            reflection.setBottomOpacity(1.0);
            reflection.setTopOffset(0.0);
            label.setEffect(reflection);
    //        Group pane = new Group();
            BorderPane pane = new BorderPane();
            pane.setCenter(label);
    //        pane.setTop(label);
    //        pane.setBottom(label);
    //        Pane pane = new StackPane();
    //        Pane pane = new FlowPane();
    //        Pane pane = new HBox();
    //        pane.getChildren().add(label);
            Scene scene = new Scene(pane, 200,200); // changes to 200 200 maybe that is reason why it does not show
            return scene;
        public static void main(String[] args) {
            Application.launch(args);
    }

  • The problem about the Stage's minWidth or minHeight property.

    From the JavaFX 2.2 api, I see the minWidth or minHeight property, and then I attempt to use them to limit the contraction of stage when dragging. But it takes no effect. Are there some implications for using these properties?
    I have finally to write some codes in the dragging listener of the stage to set manually width or height of the stage to achieve the minWidth or minHeight effect.

    Hi, here is the test case: when we resize the stage UNDECORATED by dragging, we can minimize the stage size to zero even I set the minWidth and minHeight properties at first.
    import javafx.animation.KeyFrame;
    import javafx.animation.KeyValue;
    import javafx.animation.Timeline;
    import javafx.application.Application;
    import javafx.beans.binding.DoubleBinding;
    import javafx.beans.property.ObjectProperty;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.beans.property.SimpleObjectProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.geometry.Bounds;
    import javafx.geometry.Point2D;
    import javafx.scene.Cursor;
    import javafx.scene.Node;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.ScrollPane;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.effect.Reflection;
    import javafx.scene.input.MouseEvent;
    import javafx.scene.layout.AnchorPane;
    import javafx.scene.layout.FlowPane;
    import javafx.scene.layout.Pane;
    import javafx.scene.paint.Color;
    import javafx.stage.Stage;
    import javafx.stage.StageStyle;
    import javafx.stage.Window;
    import javafx.util.Duration;
    public class TestMinSizeStage extends Application {
      private ScrollPane scrollPane;
      private ObjectProperty<Point2D> anchor = new SimpleObjectProperty<Point2D>(null);
      private SimpleDoubleProperty widthStage = new SimpleDoubleProperty();
      private SimpleDoubleProperty heightStage = new SimpleDoubleProperty();
      public static void main(String[] args) {
      launch(args);
      @Override
      public void start(final Stage primaryStage) {
      Pane mainContainer = initstage(primaryStage);
      mainContainer.getChildren().addAll(
      createButton());
      primaryStage.show();// Show the primaryStage
      private Pane initstage(Stage primaryStage) {
      primaryStage.setTitle("Hello Java");
      primaryStage.initStyle(StageStyle.TRANSPARENT);
      /* The minWidth or minHeight is for the stage "DECORATED", it has on effect to the stage non "DECORATED". */
      primaryStage.setMinWidth(600);
      primaryStage.setMinHeight(400);
      final FlowPane mainContainer = new FlowPane();
      mainContainer.setStyle(
      "-fx-background-color: white; " +
      "-fx-background-radius: 10px; " +
      "-fx-padding: 10px;" +
      "-fx-hgap: 30px; " +
      "-fx-vgap: 50px;");
      scrollPane = new ScrollPane();
      scrollPane.setStyle("-fx-background-radius: 10px;");
      scrollPane.setContent(mainContainer);
      scrollPane.setPannable(true);
      mainContainer.prefWidthProperty().bind(new DoubleBinding() {
      super.bind(scrollPane.viewportBoundsProperty());
      @Override
      protected double computeValue() {
      Bounds bounds = scrollPane.getViewportBounds();
      if (bounds == null) {
      return 0;
      } else {
      return bounds.getWidth();
      AnchorPane root = new AnchorPane();
      root.setStyle(
      "-fx-border-color: black; " +
      "-fx-border-width: 1px; " +
      "-fx-border-radius: 10px; " +
      "-fx-background-color: rgba(0, 0, 0, 0); " +
      "-fx-background-radius: 10px;");
      DropShadow dropShadow = new DropShadow();
      dropShadow.setRadius(20.0);
      // dropShadow.setSpread(0.2);
      root.setEffect(dropShadow);
      enableDragging(root);
      root.getChildren().add(scrollPane);
      AnchorPane.setTopAnchor(scrollPane, 0.0);
      AnchorPane.setRightAnchor(scrollPane, 10.0);
      AnchorPane.setBottomAnchor(scrollPane, 10.0);
      AnchorPane.setLeftAnchor(scrollPane, 10.0);
      AnchorPane superRoot = new AnchorPane();
      superRoot.getChildren().add(root);
      AnchorPane.setTopAnchor(root, 10.0);
      AnchorPane.setRightAnchor(root, 10.0);
      AnchorPane.setBottomAnchor(root, 10.0);
      AnchorPane.setLeftAnchor(root, 10.0);
      Scene scene = new Scene(superRoot, 950, 650, Color.TRANSPARENT);
      scene.getStylesheets().add(getClass().getResource("controls.css").toExternalForm());
      primaryStage.setScene(scene);
      return mainContainer;
      * Enable the root node to be dragged. Realize some drag functions.
      * @param root - the root node
      private void enableDragging(final AnchorPane root) {
      /* This mouse event is for resizing window. Define some specific cursor patterns. */
      root.setOnMouseMoved(new EventHandler<MouseEvent>() {
      public void handle(MouseEvent me) {
      if ((me.getX() > root.getWidth() - 10 && me.getX() < root.getWidth() + 10)
      && (me.getY() > root.getHeight() - 10 && me.getY() < root.getHeight() + 10)) {
      root.setCursor(Cursor.SE_RESIZE);
      } else if (me.getX() > root.getWidth() - 5 && me.getX() < root.getWidth() + 5) {
      root.setCursor(Cursor.H_RESIZE);
      } else if (me.getY() > root.getHeight() - 5 && me.getY() < root.getHeight() + 5) {
      root.setCursor(Cursor.V_RESIZE);
      } else {
      root.setCursor(Cursor.DEFAULT);
      /* when mouse button is pressed, save the initial position of screen. */
      root.setOnMousePressed(new EventHandler<MouseEvent>() {
      public void handle(MouseEvent me) {
      Window primaryStage = root.getScene().getWindow();
      anchor.set(new Point2D(me.getScreenX() - primaryStage.getX(), me.getScreenY() - primaryStage.getY()));
      widthStage.set(primaryStage.getWidth());
      heightStage.set(primaryStage.getHeight());
      /* when mouse button is released, clear the initial position of screen. */
      root.setOnMouseReleased(new EventHandler<MouseEvent>() {
      public void handle(MouseEvent me) {
      anchor.set(null);
      /* when screen is dragged, translate it accordingly. */
      root.setOnMouseDragged(new EventHandler<MouseEvent>() {
      public void handle(MouseEvent me) {
      if (anchor.get() != null) {// The drag event on the root really takes place.
      Window primaryStage = root.getScene().getWindow();
      if (root.getCursor() == Cursor.H_RESIZE) {
      primaryStage.setWidth(widthStage.get() + (me.getScreenX() - (anchor.get().getX() + primaryStage.getX())));
      } else if (root.getCursor() == Cursor.V_RESIZE) {
      primaryStage.setHeight(heightStage.get() + (me.getScreenY() - (anchor.get().getY() + primaryStage.getY())));
      } else if (root.getCursor() == Cursor.SE_RESIZE) {
      primaryStage.setWidth(widthStage.get() + (me.getScreenX() - (anchor.get().getX() + primaryStage.getX())));
      primaryStage.setHeight(heightStage.get() + (me.getScreenY() - (anchor.get().getY() + primaryStage.getY())));
      } else {// moving the stage
      primaryStage.setX(me.getScreenX() - anchor.get().getX());
      primaryStage.setY(me.getScreenY() - anchor.get().getY());
      * Define a button
      * @return a button
      private Node createButton() {
      Button button = new Button();
      button.setEffect(new Reflection());
      button.setText("Say 'Hello Java'");
      button.setOnAction(new EventHandler<ActionEvent>() {
      @Override
      public void handle(ActionEvent event) {
      System.out.println("Hello Java!");
      /* add an animation effect */
      Timeline timeline = new Timeline();
      timeline.setCycleCount(Timeline.INDEFINITE);
      timeline.setAutoReverse(true);
      timeline.getKeyFrames().addAll(
      new KeyFrame(Duration.ZERO, new KeyValue(button.opacityProperty(), 1.0)),
      new KeyFrame(new Duration(5000), new KeyValue(button.opacityProperty(), 0.0)));
      timeline.play();
      /* set CSS style */
      button.setStyle(
      "-fx-font: 14px 'Cambria'; " +
      "-fx-text-fill: #006464; " +
      "-fx-background-color: #e79423; " +
      "-fx-background-radius: 20.0; " +
      "-fx-padding: 5.0;");
      return button;

  • Effects on effects

    This may be a metaphysical question, but is there a way to set effects on effects ?
    I was playing around with Reflection and was trying to created a blurred reflection, but this does not seem to be as straightforward as I might have thought.
    Chaining effects together using setInput did not work for me because I only want to blur the reflection, not the node.

    In general setInput is the way to go to apply effects on effects, but in your case you want to apply an effect on only a partial area of the effected node, so setInput doesn't really work.
    The code below will work in some limited cases.
    This solution is probably not what you are really looking for because it is a bit clunky in implementation and limited in it's possible uses, but I don't know of a better way to accomplish the effect you desire short of creating your own effect - e.g. An EffectClip effect which limits the area that subsequent effects apply to.
    Custom effects might be realizable now that more of the JavaFX code has been open sourced.
    General strategy is:
    // construct a reflected label to be displayed in the scene.
    // show the reflected label on the stage.
    // snapshot the reflected part of the label to an image.
    // blur the reflected part of the label.
    // place the original label (now without it's original reflection)
    // in a VBox together with it's blurred reflection.
    // replace the original reflected label with the blurred reflected version.
    import javafx.application.Application;
    import javafx.geometry.Bounds;
    import javafx.geometry.Rectangle2D;
    import javafx.scene.Scene;
    import javafx.scene.SnapshotParameters;
    import javafx.scene.control.Label;
    import javafx.scene.effect.BoxBlur;
    import javafx.scene.effect.Reflection;
    import javafx.scene.image.ImageView;
    import javafx.scene.image.WritableImage;
    import javafx.scene.layout.StackPane;
    import javafx.scene.layout.VBox;
    import javafx.stage.Stage;
    public class InReflection extends Application {
      @Override public void start(Stage stage) {
        // construct a reflected label to be displayed in the scene.
        Label label = new Label("The mirror crack'd from side to side");
        label.setStyle("-fx-font-size: 40px; -fx-font-style: italic;");
        label.setEffect(new Reflection());
        // show the reflected label on the stage
        StackPane layout = new StackPane();
        layout.getChildren().setAll(label);
        stage.setScene(new Scene(layout, 800, 200));
        stage.show();
        // snapshot the reflected part of the label to an image.
        SnapshotParameters params = new SnapshotParameters();
        Bounds effectiveBounds = label.getBoundsInParent();
        params.setViewport(new Rectangle2D(effectiveBounds.getMinX(), effectiveBounds.getMinY() + effectiveBounds.getHeight() * 2 / 3, effectiveBounds.getWidth(), effectiveBounds.getHeight() * 1 /3));
        WritableImage image = label.snapshot(params, null);
        // blur the reflected part of the label.
        ImageView reflectedView = new ImageView(image);
        reflectedView.setEffect(new BoxBlur());
        // place the original label (now without it's original reflection)
        // in a VBox together with it's blurred reflection.
        VBox blurReflectedLabel = new VBox();
        label.setEffect(null);
        blurReflectedLabel.getChildren().setAll(label, reflectedView);
        blurReflectedLabel.setMinSize(Label.USE_PREF_SIZE, Label.USE_PREF_SIZE);
        blurReflectedLabel.setPrefSize(effectiveBounds.getWidth(), effectiveBounds.getHeight());
        blurReflectedLabel.setMaxSize(Label.USE_PREF_SIZE, Label.USE_PREF_SIZE);
        // replace the original reflected label with the blurred reflected version.
        layout.getChildren().setAll(blurReflectedLabel);
      public static void main(String[] args) { launch(args); }
    }

  • Updating HLineTo dynamically

    Hi,
    in this small scrolling text example, the text can be updated dynamically.
    The problem is that for longer text the start point need to adjusted further to the right and the endpoint further to the left.
    Anyone knows how to adjust the code to fix this problem?
    Thanks!
    package text;
    import javafx.animation.ParallelTransition;
    import javafx.animation.PathTransition;
    import javafx.animation.PathTransition.OrientationType;
    import javafx.animation.Timeline;
    import javafx.application.Application;
    import javafx.beans.property.SimpleDoubleProperty;
    import javafx.beans.property.SimpleFloatProperty;
    import javafx.beans.property.SimpleStringProperty;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Group;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.control.TextField;
    import javafx.scene.effect.Reflection;
    import javafx.scene.paint.Color;
    import javafx.scene.shape.CubicCurveTo;
    import javafx.scene.shape.HLineTo;
    import javafx.scene.shape.MoveTo;
    import javafx.scene.shape.Path;
    import javafx.scene.shape.Shape;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.scene.text.TextBuilder;
    import javafx.stage.Stage;
    import javafx.util.Duration;
    public class MoveText extends Application{
       private SimpleStringProperty textProperty = new SimpleStringProperty("Test");
       private SimpleFloatProperty moveTo = new SimpleFloatProperty(-80.0f);
       private TextField textField = new TextField();
       private Shape shape;
       private HLineTo hLineTo;
       @Override
       public void start(Stage stage) throws Exception
       hLineTo = new HLineTo(moveTo.getValue());
        Button btn = new Button();
        final Reflection reflection = new Reflection();
        reflection.setFraction(1.0); 
        shape = TextBuilder.create()
                    .text(textProperty.getValue()).x(580).y(20)
                    .font(Font.font(java.awt.Font.SANS_SERIF, 25))
                    .effect(reflection)
                    .build();  
          btn.setLayoutY(70);
          textField.setLayoutY(70);
          textField.setLayoutX(140);
            btn.setText("Update textProperty");
            btn.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                    ((Text)shape).setText(textField.getText());
                    moveTo.set(-textField.getText().length()*10);
          final Group group = new Group();
          final Scene scene = new Scene(group, 500, 400, Color.GHOSTWHITE);
          stage.setScene(scene);
          stage.setTitle("Animations");
          stage.show();
          final Path path = new Path();
          path.getElements().add(new MoveTo(580,20));
          path.getElements().add(hLineTo);
          path.setOpacity(0.0);
          group.getChildren().add(path);
          group.getChildren().add(shape);
          group.getChildren().add(btn);
          group.getChildren().add(textField);
          final PathTransition pathTransition = new PathTransition();
          pathTransition.setDuration(Duration.seconds(8.0));
          pathTransition.setPath(path);
          pathTransition.setNode(shape);
          pathTransition.setOrientation(OrientationType.NONE);
          pathTransition.setCycleCount(Timeline.INDEFINITE);
          final ParallelTransition parallelTransition =
             new ParallelTransition(pathTransition);
          parallelTransition.play();
       public static void main(final String[] arguments)
          Application.launch(arguments);
    }

    This is more of a complete rewrite than an adjustment, but perhaps you can use some of the concepts in the rewrite and apply them to your project.
    import javafx.animation.*;
    import javafx.application.Application;
    import javafx.beans.*;
    import javafx.event.*;
    import javafx.geometry.*;
    import javafx.scene.*;
    import javafx.scene.control.*;
    import javafx.scene.effect.Reflection;
    import javafx.scene.layout.*;
    import javafx.scene.paint.Color;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    import javafx.util.Duration;
    public class TranslateText extends Application {
      final TextField textField       = new TextField("Test");
      final Text      text            = new Text(textField.getText());
      final double    SCROLL_VELOCITY = 100; // pixels/second
            TranslateTransition transition;
      @Override public void start(Stage stage) {
        Node translatableNode = createTranslatableNode();
        HBox controls         = createControls();
        final VBox layout = new VBox(10);
        layout.getChildren().setAll(
          translatableNode,
          controls
        layout.setPrefWidth(500);
        layout.setPadding(new Insets(20, 0, 20, 0));
        scrollWithinParent(translatableNode);
        stage.setScene(new Scene(layout, Color.GHOSTWHITE));
        stage.show();
      public static void main(final String[] arguments) { Application.launch(arguments); }
      private HBox createControls() {
        final Button updateButton = new Button("Update Text");
        updateButton.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent event) {
            text.setText(textField.getText());
        textField.setOnAction(new EventHandler<ActionEvent>() {
          @Override public void handle(ActionEvent event) {
            updateButton.fire();
        final HBox controls = new HBox(10);
        controls.setAlignment(Pos.BASELINE_CENTER);
        controls.getChildren().setAll(
          updateButton,
          textField
        return controls;
      private void scrollWithinParent(final Node node) {
        if (transition != null) {
          transition.stop();
        transition = new TranslateTransition();
        transition.setNode(node);
        transition.setInterpolator(Interpolator.LINEAR);
        transition.setCycleCount(Timeline.INDEFINITE);
        node.layoutBoundsProperty().addListener(new InvalidationListener() {
          @Override public void invalidated(Observable observable) {
            setTransitionParameters(node);
        node.getParent().layoutBoundsProperty().addListener(new InvalidationListener() {
          @Override public void invalidated(Observable observable) {
            setTransitionParameters(node);
        setTransitionParameters(node);
      private void setTransitionParameters(final Node node) {
        if (node.getParent() == null) {
          throw new IllegalArgumentException("Node must have a parent assigned");
        Bounds bounds = node.getLayoutBounds();
        final double fromX = node.getParent().getLayoutBounds().getWidth();
        final double toX   = -bounds.getWidth();
        if (effectivelyEquivalent(transition.getFromX(), fromX) &&
            effectivelyEquivalent(transition.getToX(),   toX)) {
          return;
        transition.fromXProperty().set(fromX);
        transition.toXProperty().set(toX);
        transition.setDuration(
          Duration.seconds(
            Math.abs(transition.getFromX() - transition.getToX()) / SCROLL_VELOCITY
        // stop and start the transition to pick up the updated parameters
        Duration curTime = transition.getCurrentTime();
        transition.stop();
        transition.playFrom(curTime);
      private Node createTranslatableNode() {
        text.setStyle("-fx-font-size: 25px;");
        text.setEffect(new Reflection());
        return new Group(text);
      private static final double EPSILON = 0.000001;
      private boolean effectivelyEquivalent(final double a, final double b) {
        return Math.abs(a - b) < EPSILON;
    }

  • [Help!] How I connect (the index) the rectangle array to a interger array

    I'm new in javafx... but the javafx language syntax seam to be many thing new... : )
    And I got a problem... : |
    My source:
    * Main.fx
    * Created on Mar 21, 2009, 4:57:42 PM
    package canvas;
    import javafx.scene.*;
    import javafx.scene.paint.*;
    import javafx.scene.shape.*;
    import javafx.stage.*;
    import javafx.scene.text.Text;
    import javafx.scene.text.Font;
    * @author xllsllx
    Stage {
        title: "Application title"
        width: 500
        height: 500
        scene: Scene {
            var clickcount = 0;
            content:Group {
                content: for(i in [1..8], j in [1..8]){
                    var zoom = 1;
                    var recbig = 40;
                    Rectangle {
                        x: i*recbig*zoom,
                        y: j*recbig*zoom
                        width: recbig*zoom,
                        height: recbig*zoom
                        fill: Color.BLACK
                        stroke:Color.WHITE
                        strokeWidth:1
                        onMouseEntered: function( e ):Void {
                            var rect: Rectangle = e.node as Rectangle;
                            rect.fill = Color.BLUE;
                        onMouseExited: function( e ):Void {
                            var rect: Rectangle = e.node as Rectangle;
                            rect.fill = Color.BLACK;
                        onMousePressed: function( e ):Void {
                            var rect: Rectangle = e.node as Rectangle;
                            rect.fill = Color.GREEN;
                            clickcount++;
                            //How can I get the rectangle index ...?
    }*[Problem]*
    I have:
    1. int array [i..8,j..8]
    2. rectangle array [i..8,j..8]
    3. I have a rectangle array display in a window. Picture -> [http://www.onjava.com/onjava/2007/07/27/graphics/grill.gif]
    4. I add mouse click event for each rectangle
    *5*. Mine problem is "_How I get the index of the rectangle in the rectarray when I click on any display rectangle_"
    Ex: I click on Rect[col:2,row:3] and I have the return value is col:2 & row:3.
    So I can mark it on int array at col:2 & row:3
    Thank for reading my problem... and thank a lot if have any answer... : )
    And if you have any new best solution for this problem please share. : ) Thank much!!!
    Edited by: xllsllx on Mar 23, 2009 11:09 AM

    What do you mean "you can use those features of Java from JavaFX"?
    I thought that JavaFX don't have a "true multi-dimensional arrays". Because I had tried a multi-dimensional arrays but it seam to be impossible.Correct. JavaFX doesn't have multi-dimensional arrays, and it also doesn't have a lot of the capabilities found in the Java Collections API. However, because JavaFX compiles to JVM bytecode, you can use Java functionality in your JavaFX program. For example, if you need a true multi-dimensional array, you could create a Java class that contains a multi-dimensional array and exposes getters and setters. On a related note, you could use the Collections API directly, as in the example in the following post (that also demonstrates reflection in JavaFX).
    http://javafxpert.com/weblog/2009/03/answering-reader-mail-about-the-javafx-reflection-api.html
    Note that the source code in that post imports java.util.Iterator, etc. to iterate over a Java collection. It also uses java.util.Date
    A disadvantage of using these approaches is that JavaFX can't bind to POJOs (yet).
    Thanks,
    Jim Weaver
    http://JavaFXpert.com (Learn JavaFX blog)

  • Creating instance's without declaration?

    For a complicated reason, I need to be able to create instances of my JavaFX classes dynamically via classname and/or reflection. JavaFX Script is a declaritive language... if I want SomeNode{} I get it, but if someone provides me with "SomeNode" how can I take this String and get an instance of SomeNode.
    In Java it would be easy (given the absolute classname), Class.getByName("com.whatever.SomeNode").newInstance(); (or whatever the syntax is)
    Is there a back door hook via reflection on "create()" to create my custom node classes using an absolute classname?

    kinda working... can create an instance but still can't initVar().
    package com.whatever;
    public class Foo {
        public var bar: Bar;
    var x: Bar = Bar{};
    FXContext rcontext = FXContext.getInstance();
    FXClassType cls = rcontext.findClass("com.whatever.Foo");
    FXObjectValue z = cls.allocate();
    z.initVar("bar", ???HOW DO I PUT 'x' IN HERE???); //How do I supply 'x' here????
    Object o = (z.initialize() as javafx.reflect.FXLocal.ObjectValue).asObject(); //seems is strange, but does work!*I can't create a  FXValue from 'x' and use it in the method...*
    FXObjectValue  : public void initVar(java.lang.String name, javafx.reflect.FXValue value)

  • Why this doesnt work ?

    http://www.weinerso.xpg.com.br/andre/
    My friend hosted my javafx app just for fun, while we wait for the gadget for google sites.
    Anyway, it isnt working , heres the code of my app, it isnt anything fancy
    package weiner1;
    import com.sun.scenario.effect.Color4f;
    import java.awt.Insets;
    import java.awt.TextField;
    import javafx.application.Application;
    import javafx.event.ActionEvent;
    import javafx.event.EventHandler;
    import javafx.scene.Scene;
    import javafx.scene.control.Button;
    import javafx.scene.effect.DropShadow;
    import javafx.scene.effect.Reflection;
    import javafx.scene.layout.GridPane;
    import javafx.scene.layout.StackPane;
    import javafx.scene.paint.Color;
    import javafx.scene.text.Font;
    import javafx.scene.text.Text;
    import javafx.stage.Stage;
    import javax.swing.JTextField;
    * @author André
    public class Weiner1 extends Application {
         * @param args the command line arguments
        public static StackPane r;
        public static void main(String[] args) {
            launch(args);
        @Override
        public void start(Stage primaryStage) {
            Button btn = new Button();
            btn.setText("Say 'Hello World'");
            btn.setOnAction(new EventHandler<ActionEvent>() {
                @Override
                public void handle(ActionEvent event) {
                    System.out.println("Hello World!");
            StackPane root = new StackPane();
            getSP(root);
            GridPane grid = new GridPane();
            grid = new GridPane();
            TextField textField = new TextField();
            DropShadow ds = new DropShadow();
            Reflection ref = new Reflection();
            ref.setFraction(8);
            ref.setFraction(2);
            ds.setColor(Color.rgb(50,50,50,0.588));
            ds.setOffsetY(10.0);
            ds.setOffsetX(10.0);
            Text text = new Text();
            text.setText("WEINERSO!!!!");
            text.setFont(Font.font("SanSerif",30));
            text.setFill(Color.ROYALBLUE);
            text.setEffect(ds);
            text.setEffect(ref);
            settext(text);
            grid.add(btn,5,5);
            r.getChildren().add(grid);
            Scene scene = new Scene(root, 300, 250);
            primaryStage.setTitle("Hello Weiner!");
            primaryStage.setScene(scene);
            primaryStage.show();
        public static void getSP(StackPane root)
            r = root;
        public static void settext(Text text)
            r.getChildren().add(text);
    }

    Hi Andres,
    I think you must first try to run that embed javafx in plain html . What do i see in that link you gave is , the jar file "JavaFXApplication2.jar" is working perfectly I've tested them directly and it does work . There these reasons which are not running your javafx embed.
    1. Your jnlp codebase is not correct
    2. You might have some javascript invalid
    3. You might have override div 'javafx-app-placeholder' with your own content
    Thanks
    Narayan

  • Generic class attributes / methods

    Hi,
    Is it possible to access class attributes / methods generic in JavaFX?
    Like:
    function myFunc(attributeName:String) {
          myClass.<attributeName>
    }Thanks in advance.
    Edited by: toxiccrack on Aug 14, 2009 6:09 AM

    Hi
    I think you could take a look at the JavaFX Reflection API (javafx.reflect package). You can also visit this blog http://blogs.sun.com/girishr/entry/reflection_in_javafx
    Cheers

  • Where is javafx.reflect in the 1.2 sdk

    Playing with "Calling JavaFX Classes from Pure Java Code" but the system does not find "javafx.reflect" package.
    The package is referenced in the api docs, but in netbeans 6.5, the system does not find the package.
    What am I missing here?
    Regards
    Paul F Fraser

    Looks like a NetBeans specific issue, I have a program using reflection (to show JavaFX's named colors) which works fine in 1.2.
    FYI, javafx.reflect lives in javafxc.jar

  • Issue with DataApp Sample in JavaFX.

    Okay so I downloaded the Samples pack here http://jdk8.java.net/download.html or here http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html at the bottom.
    Inside is one called DataApp which requires setting up an SQL DB, and connecting to it.
    In Netbeans8 I get an error about not having RestLib api inside the DataAppClient which according to the setup DataAppClient - The JavaFX 2.0 client application. inside there you can see a package with packages that wont import such as
    import com.sun.jersey.api.client.Client;
    import com.sun.jersey.api.client.UniformInterfaceException;
    import com.sun.jersey.api.client.WebResource;
    import com.sun.jersey.api.json.JSONConfiguration;
    So why am I in a Java 8 samples pack needing FX 2? Though I'm not sure if it's FX8 yet, I just didn't think the 2.0 client would work.
    So I tried Netbeans 7.3 to see if it would work. At first the DataAppClient was fine, but I see the DataAppPreloader will not run because it uses Package javafx.something which apparently is new in Java 8.....
    So now I'm stuck, wondering why Restlib doesn't exist... I looked it up, and it says it's used for Web services, but I don't have it, nor does it say to install it in the readme.
    not existing, which I guess has to do with the RestLib?
    Anyone have any ideas?
    EDIT: So I just downloaded the version for FX2, and I am still getting the same error when I run it, though nothing shows "errors" in the packages. Maybe I just needed to run it correctly for it to work, so not what is this error tellingme
    Creating "dataapp" user and "APP" database...
    Executing commands
    Failed to execute:  INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL)
    C:\Users\Konrad\Downloads\javafx_samples-2_2_7-windows\javafx-samples-2.2.7\src\DataApp\DataAppLoader\build.xml:84:
    java.sql.SQLException: Column count doesn't match value count at row 1
         at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1073)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3609)
         at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3541)
         at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2002)
         at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2163)
         at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2618)
         at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2568)
         at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:842)
         at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:681)
         at org.apache.tools.ant.taskdefs.SQLExec.execSQL(SQLExec.java:775)
         at org.apache.tools.ant.taskdefs.SQLExec.runStatements(SQLExec.java:745)
         at org.apache.tools.ant.taskdefs.SQLExec$Transaction.runTransaction(SQLExec.java:1043)
         at org.apache.tools.ant.taskdefs.SQLExec$Transaction.access$000(SQLExec.java:985)
         at org.apache.tools.ant.taskdefs.SQLExec.execute(SQLExec.java:653)
         at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
         at sun.reflect.GeneratedMethodAccessor75.invoke(Unknown Source)
         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
         at java.lang.reflect.Method.invoke(Method.java:601)
         at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
         at org.apache.tools.ant.Task.perform(Task.java:348)
         at org.apache.tools.ant.Target.execute(Target.java:392)
         at org.apache.tools.ant.Target.performTasks(Target.java:413)
         at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
         at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
         at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
         at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
         at org.apache.tools.ant.module.bridge.impl.BridgeImpl.run(BridgeImpl.java:283)
         at org.apache.tools.ant.module.run.TargetExecutor.run(TargetExecutor.java:541)
         at org.netbeans.core.execution.RunClassThread.run(RunClassThread.java:153)
    BUILD FAILED (total time: 6 seconds)I have put the 1.18 derby file into glassfish, download and set up MySQL using a netbeans reference,I had set my root password and such as well.
    The only thing I haven't done is created a DB, but I don't think I need one, and the instructions don't say anything.
    I have Netbenans 7.3, 8, and Java vers 7_15 and 8 build 82.
    GlassFish 3.1.2 as well as 4.0 build 76 which I haven't installed.
    I hav e MySQL 5.6
    Java FX 2.0 and 8 build 82.
    The instructions are
    DataApp Installation Guide
    Table of Contents
    Prerequisites
    Setting Up the DataApp Sample
    Running the Sample
    NetBeans Projects for the Sample
    Licensing
    Prerequisites
    You must have the following software installed to run the DataApp sample:
    Java SDK 1.6.0_24 or later
    Available at http://www.oracle.com/technetwork/java/javase/downloads/index.html.
    JavaFX 2.0 SDK or later
    Available at http://javafx.com/downloads/all.jsp.
    MySQL 5.5 or later
    Available at http://dev.mysql.com/downloads/.
    You need to know the root password for your installation.
    Netbeans 7.1 with Java EE and GlassFish 3.1.1 or later
    Available at http://netbeans.org/downloads/.
    Run the NetBeans installer to install NetBeans and GlassFish to the default locations.
    Setting Up the DataApp Sample
    Install the MySQL drivers into GlassFish.
    Manually copy the mysql-connector-java-5.1.13-bin.jar file from the netbeans-install-dir\ide\modules\ext\ to the glassfish-install-dir/glassfish/lib directory, where netbeans-install-dir and glassfish-install-dir are the directories into which the products were installed. For example, on Windows the install directory for products is typically in the C:\Program Files\ or C:\Program Files (x86)\ directories.
    Open the following DataApp projects in NetBeans by selecting File ->Open Project and navigating to the location of the DataApp sample:
    DataAppClient
    DataAppLibrary
    DataAppLoader
    DataAppPreloader
    DataAppServer
    Configure and create the database (only needs to be done once):
    In NetBeans, right-click the DataAppLoader project.
    Select Run.
    Enter your MySQL root password when prompted.
    Wait until you see the message that the build has successfully finished, which takes approximately 5 to 15 minutes.
    Running the Sample
    Start the server:
    In NetBeans, right-click the DataAppServer project.
    Select Run.
    Wait until a browser window opens that says: YOU ARE DONE!
    (Optional) Start the standalone client:
    In NetBeans, right-click the DataAppClient project.
    Select Run.
    NetBeans Projects for the Sample
    DataAppLibrary - Contains the following data:
    Database tables
    ORM model to database tables
    DataAppLoader - Application that is run once to perform the following tasks:
    Creates the database.
    Loads all of the static data for the data app.
    Creates some historical data.
    DataAppServer - Web server that performs the following tasks:
    Simulates auto sales and persists them to the database.
    Provides access to the database through web services.
    DataAppClient - The JavaFX 2.0 client application.
    Licensing
    The license for the DataAppLoader/zip_code_inserts.sql file is the Creative Commons Attribution-ShareAlike license, which is available at http://creativecommons.org/licenses/by-sa/2.0/.
    The license for all other files is the BSD style license:
    * Copyright (c) 2008, 2011 Oracle and/or its affiliates.
    * All rights reserved. Use is subject to license terms.
    * This file is available and licensed under the following license:
    * Redistribution and use in source and binary forms, with or without
    * modification, are permitted provided that the following conditions
    * are met:
    * - Redistributions of source code must retain the above copyright
    * notice, this list of conditions and the following disclaimer.
    * - Redistributions in binary form must reproduce the above copyright
    * notice, this list of conditions and the following disclaimer in
    * the documentation and/or other materials provided with the distribution.
    * - Neither the name of Oracle Corporation nor the names of its
    * contributors may be used to endorse or promote products derived
    * from this software without specific prior written permission.
    * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
    * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
    * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
    * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
    * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
    * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
    * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
    * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
    * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    Copyright © 2011, Oracle and/or its affiliates. All rights reservedEdited by: KonradZuse on Mar 27, 2013 9:39 AM
    Edited by: KonradZuse on Mar 27, 2013 9:51 AM
    Edited by: KonradZuse on Mar 27, 2013 9:58 AM

    I found the same issue but resolved it by myself. The user table of the MySQL changed, my guess. You need to add another 'Y' or 'N' to the end of this statement in the build.xml of DataAppLoader:
    INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL,'N');
    The original one is like this:
    INSERT INTO user VALUES ('localhost','dataapp','*B974A83D18BB105D0C9186756F485406E6E6039B','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','Y','','','','',0,0,0,0,'',NULL);
    The new column added is password_expired. Y or N to indicate the password is good or not.

  • Deployment of JavaFX Web application on client machine(Windows OS.)

    Problem Statement:
    Deployment of JavaFX Web application on client machine(Windows OS.)
    Error: unable to load the native libarary(JNI Windows dll) i.e. throws java.lang.UnsatisfiedLinkError exception.
    Problem Description:
    I have create the JavaFX application which have dependency on Native library written in Java Native Interface(JNI).
    When the application is deployed on Apache 6.0 Tomcat Server(Copied .html file *.jnlp file and .jar file) and when client machine hit the html page in internet explorer version 8.0 its throws the following error(java.lang.UnsatisfiedLinkError: no JNIHelloWorld in java.library.path)
    Note:
    I have created the jar file which have my "JNIHelloWorld' native library dll in root directory. I have signed the jar with same signature which i have used for signing for my application Jar file.
    I have mentioned the native library jar in JNLP file resource keyword as follows:
    <resources os=Windows>
    <nativelib href="JNIHelloWorld.jar" download="eager" />
    </resources>
    The complete jnlp file content is in "JavaFXApplication.jnlp file:" section below.
    The description of error is as follows:
    Match: beginTraversal
    Match: digest selected JREDesc: JREDesc[version 1.6+, heap=-1--1, args=null, href=http://java.sun.com/products/autodl/j2se, sel=false, null, null], JREInfo: JREInfo for index 0:
    platform is: 1.7
    product is: 1.7.0_07
    location is: http://java.sun.com/products/autodl/j2se
    path is: C:\Program Files\Java\jre7\bin\javaw.exe
    args is: null
    native platform is: Windows, x86 [ x86, 32bit ]
    JavaFX runtime is: JavaFX 2.2.1 found at C:\Program Files\Java\jre7\
    enabled is: true
    registered is: true
    system is: true
         Match: ignoring maxHeap: -1
         Match: ignoring InitHeap: -1
         Match: digesting vmargs: null
         Match: digested vmargs: [JVMParameters: isSecure: true, args: ]
         Match: JVM args after accumulation: [JVMParameters: isSecure: true, args: ]
         Match: digest LaunchDesc: http://10.187.143.68:8282/KPIT/JavaFXApplication20.jnlp
         Match: digest properties: []
         Match: JVM args: [JVMParameters: isSecure: true, args: ]
         Match: endTraversal ..
         Match: JVM args final:
         Match: Running JREInfo Version match: 1.7.0.07 == 1.7.0.07
         *Match: Running JVM args match: have:<> satisfy want:<>*
    *java.lang.UnsatisfiedLinkError: no JNIHelloWorld in java.library.path*
    *     at java.lang.ClassLoader.loadLibrary(Unknown Source)*
    *     at java.lang.Runtime.loadLibrary0(Unknown Source)*
    *     at java.lang.System.loadLibrary(Unknown Source)*     at javafxapplication20.JavaFXApplication20.<clinit>(JavaFXApplication20.java:41)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
         at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
         at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
         at java.lang.reflect.Constructor.newInstance(Unknown Source)
         at java.lang.Class.newInstance0(Unknown Source)
         at java.lang.Class.newInstance(Unknown Source)
         at com.sun.javafx.applet.FXApplet2.init(FXApplet2.java:63)
         at com.sun.deploy.uitoolkit.impl.fx.FXApplet2Adapter.init(FXApplet2Adapter.java:207)
         at sun.plugin2.applet.Plugin2Manager$AppletExecutionRunnable.run(Unknown Source)
         at java.lang.Thread.run(Unknown Source)
    Java Plug-in 10.7.2.11
    Using JRE version 1.7.0_07-b11 Java HotSpot(TM) Client VM
    User home directory = C:\Users\io839
    Please find my native library code and JavaFX application code:
    Native library JNI Code:
    JavaFXApplication.java:
    JNIEXPORT jstring JNICALL Java_javafxapplication_SampleController_printString(JNIEnv *env, jobject envObject)
         string str = "hello JNI";
         jstring jniStr = env->NewStringUTF(str.c_str());
         return jniStr;
    JavaFX Application code:
    JavaFXApplication.java:
    package javafxapplication;
    import javafx.application.Application;
    import javafx.fxml.FXMLLoader;
    import javafx.scene.Parent;
    import javafx.scene.Scene;
    import javafx.stage.Stage;
    public class JavaFXApplication extends Application {
    @Override
    public void start(Stage stage) throws Exception {
    Parent root = FXMLLoader.load(getClass().getResource("Sample.fxml"));
    Scene scene = new Scene(root);
    stage.setScene(scene);
    stage.show();
    * The main() method is ignored in correctly deployed JavaFX application.
    * main() serves only as fallback in case the application can not be
    * launched through deployment artifacts, e.g., in IDEs with limited FX
    * support. NetBeans ignores main().
    * @param args the command line arguments
    public static void main(String[] args) {
    launch(args);
    static{
    System.loadLibrary("JNIHelloWorld");
    SampleController.java file:
    package javafxapplication;
    import java.net.URL;
    import java.util.ResourceBundle;
    import javafx.event.ActionEvent;
    import javafx.fxml.FXML;
    import javafx.fxml.Initializable;
    import javafx.scene.control.Label;
    public class SampleController implements Initializable {
    @FXML
    private Label label;
    private native String printString();
    @FXML
    private void handleButtonAction(ActionEvent event) {
    System.out.println("You clicked me!");
    String str = printString();
    label.setText(str);
    @Override
    public void initialize(URL url, ResourceBundle rb) {
    // TODO
    //String str = printString();
    JavaFXApplication.jnlp file:
    <?xml version="1.0" encoding="utf-8"?>
    <jnlp spec="1.0" xmlns:jfx="http://javafx.com" href="JavaFXApplication.jnlp">
    <information>
    <title>JavaFXApplication20</title>
    <vendor>io839</vendor>
    <description>Sample JavaFX 2.0 application.</description>
    <offline-allowed/>
    </information>
    <resources>
    <jfx:javafx-runtime version="2.2+" href="http://javadl.sun.com/webapps/download/GetFile/javafx-latest/windows-i586/javafx2.jnlp"/>
    </resources>
    <resources>
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="JavaFXApplication.jar" size="20918" download="eager" />
    </resources>
    <resources os=Windows>
    <nativelib href="JNIHelloWorld.jar" download="eager" />
    </resources>
    <security>
    <all-permissions/>
    </security>
    <applet-desc width="800" height="600" main-class="com.javafx.main.NoJavaFXFallback" name="JavaFXApplication" >
    <param name="requiredFXVersion" value="2.2+"/>
    </applet-desc>
    <jfx:javafx-desc width="800" height="600" main-class="javafxapplication.JavaFXApplication" name="JavaFXApplication" />
    <update check="always"/>
    </jnlp>

    No problem.
    Make sure your resources are set at the proper location. Could be that tje jni.jar is under a 'lib' folder?
    Normally you don't have to worry about deployment a lot if you are using like Netbeans 7.2 or higher.
    When you press 'Clean and build' it creates your deployed files in the 'dist' folder.
    You can change specification by adapting the build.xml file.
    Of course lot of different possibilities are available for deployment!
    You can find lot of info here:
    [http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm|http://docs.oracle.com/javafx/2/deployment/jfxpub-deployment.htm]
    Important to know is if you want to work with
    - a standalone application (self-contained or not)
    - with webstart
    - or with applets
    (In my case I'm using webstart, but also Self-Contained Application Packaging (jre is also installed!)

Maybe you are looking for

  • Should I buy a Mac Mini (new or refurbished)?

    Wasn't sure if this was the correct place to make this post. If not, please accept my apologies... I have a 5-year-old Dell desktop with a 40GB HD and Windows XP. Am sure the HD will give up the ghost one of these days. I had put more memory (1GB) in

  • Critical Irish Update needed to solve black and white tv problem on G20!

    I recently had trouble with setting up tv on my Qosmio G20, I was pointed in the direction of a black and white problem that affects earlier models. The solution to the problem was to use the g20's drivers and run 2 reg files. Having done that to no

  • Can no longer reply, reply all or forward email

    I have an iPad Air 2 and use the internet (outlook to access my email...sorry, just the way I learned). Just recently I can no longer reply to, reply to all or forward to my email, only read.  I have not changed any settings nor done a recent update.

  • Auto Source determination not happening

    Hi Guruz, I have a material assigned to a quota arrangement usage in material master - MRP 2 View. Source list maintained for the material/plant with 2 vendor codes and both releveant for MRP '1' Quota arrangement maintained with proper validity peri

  • AirPrt Express dissapears from AirPort Utility after working fine for a bit

    I got an Airport Express, set it up as connect to existing wifi network. All works fine, and the speakers show up in ITunes. But then suddenly after a couple of minutes of working fine, it just disappears from iTunes, and is also gone from AirPort Ut