Manning JavaFX In Action Nov 2009 ISBN 1933988991 pdf

Covers JavaFX v1.2

IN ACTION
Simon Morris

MANNING

JavaFX in Action

JavaFX
in Action
SIMON MORRIS

MANNING
Greenwich
(74° w. long.)

For online information and ordering of this and other Manning books, please visit
www.manning.com. The publisher offers discounts on this book when ordered in quantity.
For more information, please contact
Special Sales Department

Manning Publications Co.
Sound View Court 3B
Greenwich, CT 06830
email: orders@manning.com
©2010 by Manning Publications Co. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted, in
any form or by means electronic, mechanical, photocopying, or otherwise, without prior written
permission of the publisher.

Many of the designations used by manufacturers and sellers to distinguish their products are
claimed as trademarks. Where those designations appear in the book, and Manning
Publications was aware of a trademark claim, the designations have been printed in initial caps
or all caps.
Recognizing the importance of preserving what has been written, it is Manning’s policy to have
the books we publish printed on acid-free paper, and we exert our best efforts to that end.
Recognizing also our responsibility to conserve the resources of our planet, Manning books are
printed on paper that is at least 15% recycled and processed without the use of elemental chlorine.

Manning Publications Co.
Sound View Court 3B

Greenwich, CT 06830

Development Editor:
Copyeditor:
Proofreader:
Typesetter:
Cover designer:

ISBN 978-1-933988-99-3
Printed in the United States of America
1 2 3 4 5 6 7 8 9 10 – MAL – 14 13 12 11 10 09

Tom Cirtin
Linda Recktenwald
Elizabeth Martin
Gordan Salinovic
Leslie Haimes

To my father, the coolest folk singer this side of the Mersey.
(Be honest, Dad, if you’d known how obsessed I was going to get,

would you have agreed to buy my first computer?)

contents
preface xiii
acknowledgments xv
about this book xvii
about the title xxi
about the cover illustration

1

xxii

Welcome to the future: introducing JavaFX 1
1.1

Introducing JavaFX

2


Why do we need JavaFX Script? The power of a DSL 2 Back to
the future: the rise of the cloud 4 Form follows function: the fall
and rebirth of desktop Java 6




1.2
1.3
1.4

Minimum effort, maximum impact: a quick shot of JavaFX 8
Comparing Java and JavaFX Script: “Hello JavaFX!” 10
Comparing JavaFX with Adobe AIR, GWT, and Silverlight 11
Adobe AIR and Flex 11 Google Web Toolkit 11
Silverlight 12 And by comparison, JavaFX 12





1.5
1.6

But why should I buy this book?
Summary 13

vii

12



Microsoft

viii

CONTENTS

2


JavaFX Script data and variables 15
2.1
2.2

Annotating code with comments
Data types 17

16

Static, not dynamic, types 17 Value type declaration 17
Initialize-only and reassignable variables (var, def) 20
Arithmetic on value types (+, -, etc.) 21 Logic operators (and, or,
not, , =, >=,