Skip to main content

Weaver book - Example code works on JavaFXPad but not on Eclipse

7 replies [Last post]
Joined: 2008-02-18


I am new to JavaFX and am working through James Weaver's JavaFX ebook, which is excellent. I have been using MyEclipse with the JavaFX Eclipse plugin, and have been running example code as JavaFX Applications within MyEclipse with no problems, until now.

The code I am trying to run is GroupTextAndEllipse.fx in Chapter 5. If I run the code using JavaFXPad, it behaves exactly as described in the text. However, if I run it within MyEclipse, the application with text and eclipse is displayed, the mouse pointer changes to a hand correctly, but clicking or dragging with the mouse does nothing. Putting println statements within the code shows that the CanvasMouseEvents are being handled correctly, but the transform is not happening.

Does anyone have any ideas why this wouldn't work in Eclipse, and if there is any solution?

I haven't posted the code here as it loses formatting, I'm happy to post it if required.

Any help much appreciated,

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2007-05-18

Emma, et al,

Thanks for your kind words. I've been suggesting to readers that they begin moving to compiled JavaFX Script, as the interpreted version is really just a prototype, and the compiled version is progressing nicely. Until you decide to make the leap, you can use javafx from the command line to invoke interpreted JavaFX Script applications (it's covered in the book).

Regarding moving on to compiled JavaFX Script, the concepts and APIs in the book translate well, but a lot of the syntax has changed, and some new concepts have been introduced. I'd like to point you to two resources:

1) A series of articles that starts from the beginning. The first installment can be found at:

2) The "Helping you become a JavaFXpert" weblog:

The "Converting Your Second JavaFX Script Program to Compiled Syntax" post walks through the second example in the book converted to compiled JavaFX Script. I'd recommend starting with that post and working forward in time through the weblog entries.

If you have any questions on any of the blog entries, please post a comment. By the way, I do plan on updating the JavaFX Script book to the compiled JavaFX Script version, and have begun porting the examples. It would be a great "exercise for the reader" to convert the GroupTextAndEllipse.fx program to compiled JavaFX Script, but if you give up and request the source code, I'll post it on the blog :-)

Thanks again,
Jim Weaver
JavaFX BootCamp is coming to Indianapolis on April 9-11, 2008.
Watch for details!

Joined: 2007-07-12

Do you try to update javafxrt.jar and Filters.jar libraries in JavaFX Script plugin for Eclipse?

Joined: 2008-02-18

Hi, I've tried updating the plugin using the site

Eclipse says there's nothing to update. I've uninstalled/installed the plugin from this site again, still no joy.

Joined: 2007-07-12

The problem is that JavaFX runtime libraries have been updated but Eclipse plugin has not.
You can manually copy javafxrt.jar and Filters.jar libraries from
file to the plugin installation dir.

Joined: 2008-02-18

Brilliant, thank you - it was the javafxrt.jar library that needed updating.

best wishes,

Joined: 2007-07-12

May be you need to update JavaFX libraries. See the latest version on

You can post your code using [ code ] [ /code ] tags:
[code] class A{} [/code]

Joined: 2008-02-18

Thanks for that - I'd tried with no success. Here it is:

import javafx.ui.*;
import javafx.ui.canvas.*;

Frame {
title: "Text and Ellipse in a Group"
height: 600
width: 600
visible: true
content: Canvas {
content: Group {
var rotAngle = 0
var scaleFactorX = 1
var scaleFactorY = 1
var transX = 300
var transY = 200
transform: bind [
translate(transX, transY),
rotate(rotAngle, 0, 0),
scale(scaleFactorX, scaleFactorY)
content: [
Ellipse {
var: self
onMouseEntered: operation(mEvt) {
self.cursor = HAND;
onMouseClicked: operation(mEvt) {
if (mEvt.isControlDown() and mEvt.isShiftDown()) {
rotAngle -= 10;
else if (mEvt.isControlDown()) {
rotAngle += 10;
else if (mEvt.isShiftDown()) {
scaleFactorX *= .8;
scaleFactorY *= .8;
else {
scaleFactorX *= 1.25;
scaleFactorY *= 1.25;
onMouseDragged: operation(mEvt) {
transX += mEvt.dragTranslation.x;
transY += mEvt.dragTranslation.y;
strokeWidth: 5
stroke: red
fill: white
cx: 0
cy: 0
radiusX: 250
radiusY: 50
Text {
font: Font {
faceName: "Sans Serif"
style: BOLD
size: 24
x: -180
y: -10
content: "Text and Ellipse in a Group"